Skip to content

feat(common-utils): SLO fast and slow burn rules - #3789

Open
alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-01-schemafrom
alex/HDX-3001-slo-02-burn-rules
Open

alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-01-schemafrom
alex/HDX-3001-slo-02-burn-rules

Conversation

@alex-fedotyev

@alex-fedotyev alex-fedotyev commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the two burn checks an SLO is judged by: fast burn, when 2% of the
window's error budget is spent within an hour, and slow burn, when 5% is
spent within 6 hours. Each also needs a short window, a twelfth of the
long one, to burn as fast, so it stops holding soon after a burn stops,
and a minimum of events. The burn rate threshold follows from the SLO
window (14.4x and 6x for 30 days, 3.36x and 1.4x for 7 days), so both
windows alert on the same share of their budget. describeSloAlertRule
gives each rule as one sentence, for the builder, the Alerts page,
notifications and MCP to share.

Stack

Second 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 on main, one squashed commit each. Each diff is only its own change, and CI runs as if each PR targets main.

  1. feat(common-utils): SLO definition schema #3788 common-utils: SLO definition schema
  2. feat(common-utils): SLO fast and slow burn rules #3789 common-utils: SLO fast and slow burn rules (this PR)
  3. feat(common-utils): SLO alert targets and status types #3790 common-utils: SLO alert targets and status types
  4. feat(common-utils): SLO counts query #3791 common-utils: SLO counts query
  5. feat(common-utils): SLO stats and state #3792 common-utils: SLO stats and state
  6. feat(common-utils): SLO history and ordering #3793 common-utils: SLO history and ordering
  7. feat(api): SLO definitions behind ENABLE_SLOS #3794 api: SLO definitions behind ENABLE_SLOS
  8. feat(api): refresh SLO statuses in the check-alerts task #3795 api: refresh SLO statuses in the check-alerts task
  9. feat(api): SLO burn alerts as their own alert source #3796 api: SLO burn alerts as their own alert source
  10. feat(api): keep SLO alerts out of the external alerts API #3797 api: keep SLO alerts out of the external alerts API
  11. feat(api): evaluate SLO burn alerts and notify #3798 api: evaluate SLO burn alerts and notify
  12. feat(api): clickstack_get_slo MCP tool #3799 api: clickstack_get_slo MCP tool
  13. feat(api): SLO preview, save and delete MCP tools #3800 api: SLO preview, save and delete MCP tools
  14. feat(app): SLO list page behind NEXT_PUBLIC_ENABLE_SLOS #3801 app: SLO list page behind NEXT_PUBLIC_ENABLE_SLOS
  15. feat(app): search, filter, sort and delete SLOs in the list #3802 app: search, filter, sort and delete SLOs in the list
  16. feat(app): SLO builder for a new SLO #3803 app: SLO builder for a new SLO
  17. feat(app): SLO objective, details and editing in the builder #3804 app: SLO objective, details and editing in the builder
  18. feat(app): eligible-event filters and the latency template in the builder #3805 app: eligible-event filters and the latency template in the builder
  19. feat(app): preview an SLO in the builder before saving it #3806 app: preview an SLO in the builder before saving it
  20. feat(app): create an SLO from a search, and duplicate an SLO #3807 app: create an SLO from a search, and duplicate an SLO
  21. feat(app): SLO detail page #3808 app: SLO detail page
  22. feat(app): bad events flyout on the SLO page #3809 app: bad events flyout on the SLO page
  23. feat(app): SLI, error budget and burn rate charts on the SLO page #3810 app: SLI, error budget and burn rate charts on the SLO page
  24. feat(app): fast and slow burn alerts in the SLO builder, list and page #3811 app: fast and slow burn alerts in the SLO builder, list and page
  25. feat(app): SLO alerts on the Alerts page #3812 app: SLO alerts on the Alerts page
  26. feat(app): group-by in the SLO builder #3813 app: group-by in the SLO builder
  27. feat(app): grouped SLOs in the list and on the SLO page #3814 app: grouped SLOs in the list and on the SLO page

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) and NEXT_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:

  1. cd packages/common-utils && npx jest src/core/__tests__/slo.test.ts: the thresholds per window (14.4x and 6x for 30 days, 3.36x and 1.4x for 7 days) and the one-sentence rule descriptions are covered.

Test plan

  • unit: core/__tests__/slo.test.ts (thresholds per window, rule sentences)
  • typecheck and knip at this commit, for every package

How to test on Vercel preview

N/A, non-UI change.

References

  • Linear Issue: HDX-3001
  • Related PRs: the rest of this stack, listed above

[no-changeset: allow] The changeset for this piece is in part 6.

[as-cast: allow] The cast check matches the word "as" in comments and strings here; the diff has no as casts.

Adds the two burn checks an SLO is judged by: fast burn, when 2% of the
window's error budget is spent within an hour, and slow burn, when 5% is
spent within 6 hours. Each also needs a short window, a twelfth of the
long one, to burn as fast, so it stops holding soon after a burn stops,
and a minimum of events. The burn rate threshold follows from the SLO
window (14.4x and 6x for 30 days, 3.36x and 1.4x for 7 days), so both
windows alert on the same share of their budget. describeSloAlertRule
gives each rule as one sentence, for the builder, the Alerts page,
notifications and MCP to share.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 24, 2026 6:35pm UTC
hyperdx-storybook Ready Ready Preview Nov 24, 2026 6:35pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f86ea60

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 107 in total (1.12%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 478 passed • 1 skipped • 1187s

Status Count
✅ Passed 478
❌ Failed 0
⚠️ Flaky 10
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@alex-fedotyev
alex-fedotyev marked this pull request as ready for review November 24, 2026 18:48
@alex-fedotyev
alex-fedotyev requested a review from a team as a code owner November 24, 2026 18:48
@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 1
  • Production lines changed: 143 (+ 23 in test files, excluded from tier calculation)
  • Branch: alex/HDX-3001-slo-02-burn-rules
  • Author: alex-fedotyev

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

4 finding(s): 🔴 0 P0/P1 · 🟡 0 P2 · 🔵 4 P3

No inline comments. 4 P3 folded at the bottom.

🔵 4 P3 — no action needed before merge
  • 🔵 P3 packages/common-utils/src/slo.ts:146 — getSloBurnWindowMs and the hardcoded minutes ternary duplicate ALERT_INTERVAL_TO_MINUTES → SloBurnWindow ('5m' | '30m' | '1h' | '6h') is a subset of AlertInterval, and ALERT_INTERVAL_TO_MINUTES in packages/common-utils/src/types.ts:846 already maps every one of them. That breaks the REQUIRED DRY rule. Declare type SloBurnWindow = Extract<AlertInterval, '5m' | '30m' | '1h' | '6h'>, compute getSloBurnWindowMs as ALERT_INTERVAL_TO_MINUTES[window] * 60_000, and replace line 132's === '15m' ? 15 : 5 with ALERT_INTERVAL_TO_MINUTES[getSloAlertInterval(rule)]. As it stands, changing an interval to '30m' would silently print 'Checked every 5 minutes'.
  • 🔵 P3 packages/common-utils/src/slo.ts:72 — Rule properties are split between SLO_BURN_CONDITIONS and separate per-rule ternaries → getSloBurnCondition picks an entry by array index, while getSloAlertInterval and getSloAlertRuleLabel keep each rule's interval and label in their own rule === 'slowBurn' ? … : … ternaries. Adding a third rule or reordering the array means editing several places by hand, and nothing checks they agree. Key the table by rule, e.g. Record<SloAlertRule, SloBurnCondition & { interval; label }>, and have the three getters read from that one table.
  • 🔵 P3 packages/common-utils/src/slo.ts:100 — describeSloLastWindow and getSloAlertRuleLabel have no callers at this commit → Grep finds no use of describeSloLastWindow or getSloAlertRuleLabel anywhere in packages/, and neither has a test. Either move them to the stack PR that first calls them, or add a test so they are exercised here.
  • 🔵 P3 packages/common-utils/src/core/__tests__/slo.test.ts:66 — Two of the four burn thresholds the PR describes are never asserted → The PR says it covers 'thresholds per window', but the test only checks fastBurn/30d (14.4x) and slowBurn/7d (1.4x). Add direct getSloBurnThreshold assertions for slowBurn/30d (6x) and fastBurn/7d (3.36x), so a regression in the window-ratio or rounding math for those pairs would fail the test.

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.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a small, additive, pure-logic change to packages/common-utils/src/slo.ts: new burn-rule constants, window/threshold math, and sentence-describing helpers, plus one test. The four burn-rate thresholds were independently verified to compute exactly (30d/1h=14.4x, 30d/6h=6x, 7d/1h=3.36x, 7d/6h=1.4x), the Math.round(x*100)/100 guard removes floating-point tails, and every switch covers all four SloBurnWindow members. The main gaps are in test coverage, not behavior.

🟡 P2 -- recommended

  • packages/common-utils/src/core/__tests__/slo.test.ts:66 -- Only two of the four rule×window threshold combinations are asserted (fastBurn/30d=14.4x and slowBurn/7d=1.4x); the slowBurn/30d=6x and fastBurn/7d=3.36x paths that drive real alerting are never exercised, so a wrong value there would ship undetected.
    • Fix: Add assertions for describeSloAlertRule('slowBurn', '30d') and describeSloAlertRule('fastBurn', '7d') pinning the 6x and 3.36x strings.
    • testing, correctness
  • packages/common-utils/src/core/__tests__/slo.test.ts:77 -- describeSloAlertRuleDetails is asserted only for fastBurn, leaving the slowBurn sentence (30-minute short window, 100 events, 6 hours, 15-minute cadence) entirely uncovered.
    • Fix: Add an assertion for describeSloAlertRuleDetails('slowBurn') against its expected sentence.
    • testing
🔵 P3 nitpicks (3)
  • packages/common-utils/src/slo.ts:132 -- describeSloAlertRuleDetails re-derives minutes via getSloAlertInterval(rule) === '15m' ? 15 : 5, duplicating the interval-to-minutes knowledge already owned by ALERT_INTERVAL_TO_MINUTES and silently falling back to 5 for any other interval.
    • Fix: Replace the ternary with ALERT_INTERVAL_TO_MINUTES[getSloAlertInterval(rule)].
    • correctness, maintainability, kieran-typescript
  • packages/common-utils/src/slo.ts:73 -- getSloBurnCondition selects by positional index (SLO_BURN_CONDITIONS[1]/[0]), coupling correctness to array ordering with no type-level guard even though each entry carries a rule field.
    • Fix: Select by field, e.g. SLO_BURN_CONDITIONS.find(c => c.rule === rule)!.
    • maintainability, kieran-typescript
  • packages/common-utils/src/slo.ts:87 -- The switch statements in formatSloBurnWindow and getSloBurnWindowMs have no never-guarded default, and tsconfig.base.json sets noImplicitReturns: false, so a future SloBurnWindow member would compile while returning undefined.
    • Fix: Add a default branch assigning the operand to a never-typed local in both switches.
    • kieran-typescript

Reviewers (6): correctness, testing, maintainability, project-standards, kieran-typescript, learnings-researcher.

Testing gaps: getSloAlertRuleLabel, describeSloLastWindow, getSloBurnThreshold, getSloWindowMs, and getSloBurnWindowMs are exported but have no direct unit coverage — exercised only indirectly (or not at all) through the describe* string assertions; the '30m'/'5m' switch cases and the '15m' interval branch are never reached.

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

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — f86ea602 Deployed Nov 24, 2026 by vercel[bot]
Preview – hyperdx-storybook — f86ea602 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant