chore: implement phase 4 - #2782
Conversation
📊 API Diff Results
|
28b0170 to
8e00518
Compare
e38c815 to
904571c
Compare
904571c to
034847e
Compare
034847e to
ee1286d
Compare
There was a problem hiding this comment.
🟡 Changes recommended
There are correctness and API-surface issues in the new scheduling code/tests (including misleading test expectation output and missing validation/guards) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Implements “phase 4” scheduling primitives for grafana-alertcheck by deriving per-rule and global timing thresholds, introducing a per-rule scheduler, and adding a schedule feasibility (“budget”) check, with accompanying tests.
Changes:
- Added
schedule.gowithDeriveTimings,Scheduler,CheckBudget, andStartupSummary. - Moved
skewHardLimitfromsource.gointo the new schedule constants block. - Added comprehensive unit tests for timing derivation, scheduling behavior, budget checks, and a new resolve form test.
File summaries
| File | Description |
|---|---|
| grafana-alertcheck/internal/gate/source.go | Moves skewHardLimit out of source.go now that scheduling code exists. |
| grafana-alertcheck/internal/gate/schedule.go | Adds timing derivation, per-rule scheduler, budget check, and startup summary formatting. |
| grafana-alertcheck/internal/gate/schedule_test.go | Adds tests covering timing derivation, scheduler ordering/cadence, budget failure modes, and startup summary warnings. |
| grafana-alertcheck/internal/gate/resolve_test.go | Adds test coverage for resolving the Folder/Title alert name form. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| for _, uid := range uids { | ||
| rt, m := t[uid], measured[uid] | ||
| utilization += float64(m) / float64(rt.pollEvery) | ||
| if t[tightestUID].pollEvery > rt.pollEvery { | ||
| tightestUID = uid | ||
| } | ||
| if m > maxMeasured { | ||
| maxMeasured, maxMeasuredUID = m, uid | ||
| } | ||
| if m > rt.pollEvery { | ||
| overCadence = append(overCadence, uid) | ||
| } | ||
| } |
ee1286d to
c36b86f
Compare
Add per-rule poll timings, scheduler, and budget check (P4). - schedule.go: DeriveTimings, Scheduler, CheckBudget (§5) - Address review: add Folder/Title resolve test, rename CheckBudget's minPollEvery to tightestUID
c36b86f to
cc2dd22
Compare
Adds per-rule poll timings, the scheduler, and the budget check.
Review focus:
schedule.go—DeriveTimings,Scheduler,CheckBudget.