Repository navigation
feat(common-utils): SLO history and ordering - #3793
alex-fedotyev wants to merge 1 commit into
Conversation
Adds the history behind the SLO charts, computed on read from bucketed counts: the SLI per bucket, the error budget burndown over the displayed window, and the burn rate over the trailing burn window, as the alerts read it. Also adds worst first ordering for SLO lists: by state, then by budget left, then by name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 2b18fb7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
E2E Test Results✅ All tests passed • 476 passed • 1 skipped • 1099s
Tests ran across 4 shards in parallel. |
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
| trailingEligible += b.eligible; | ||
| trailingGood += b.good; | ||
| // Buckets that ended before the burn window began drop out. | ||
| const windowStart = b.ts + bucketMs - burnWindowMs; |
There was a problem hiding this comment.
🟡 P2 — Burn window shorter than (or not a multiple of) the bucket silently drops the current bucket, so every burnRate is null
With getSloHistoryGranularity buckets (30m for 7d, 1h for 30d, core/slo.ts:141) and a 5m or 30m burn window (getSloBurnWindowMs, slo.ts:152), windowStart = b.ts + bucketMs - burnWindowMs is later than b.ts, so the loop pops the bucket it just pushed and the burn rate comes back null for every point. A 1h window over 30m buckets is fine, but a 45m window would drop the straddling bucket entirely. Always keep the current bucket (trailing.length > 1), or check that burnWindowMs is a positive multiple of bucketMs and throw if not. Add a test for 30m buckets with a 5m or 30m window.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
PR Review
4 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 3 P3 1 posted as inline comment(s) on the changed lines. 3 P3 folded at the bottom. 🔵 3 P3 — no action needed before merge
Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. The two new functions were traced against their tests and against the alert-counting semantics in 🟡 P2 — recommended
🔵 P3 nitpicks (3)
Reviewers (7): correctness, testing, maintainability, project-standards, kieran-typescript, performance, previous-comments. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
Summary
Adds the history behind the SLO charts, computed on read from bucketed
counts: the SLI per bucket, the error budget burndown over the displayed
window, and the burn rate over the trailing burn window, as the alerts read
it. Also adds worst first ordering for SLO lists: by state, then by budget
left, then by name.
Stack
Part 6 of 27 PRs in a GitHub stack (stack #3815). The header says this PR merges into the branch below it, but the stack's base is
main: merging a PR lands it and every PR below it onmain, one squashed commit each. Each diff is only its own change, and CI runs as if each PR targetsmain.Parts 1 to 6 are shared code, 7 to 13 the API and its MCP tools, and 14 to 27 the app. Everything ships behind
ENABLE_SLOS(API) andNEXT_PUBLIC_ENABLE_SLOS(app), both off by default.How to reproduce
Starting point: a checkout of this branch.
On
main: nothing to compare; this is new code.On this branch:
cd packages/common-utils && npx jest src/core/__tests__/sloStats.test.ts: the burndown ends at the budget left, the burn rate reads the trailing window in time rather than in buckets, and SLOs sort worst first.Test plan
core/__tests__/sloStats.test.ts(history, ordering); all common-utils unit testsHow to test on Vercel preview
N/A, non-UI change.
References