Skip to content

feat(app): SLI, error budget and burn rate charts on the SLO page - #3810

Open
alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-22-app-bad-eventsfrom
alex/HDX-3001-slo-23-app-charts
Open

alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-22-app-bad-eventsfrom
alex/HDX-3001-slo-23-app-charts

Conversation

@alex-fedotyev

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

Copy link
Copy Markdown
Contributor

Summary

Adds three charts to the SLO page over the window, from the same bucketed
query as the numbers above them, so both describe the same moment: the SLI
per bucket against the target, with the periods below it shaded; the error
budget left, with the overspent part shaded; and the burn rate over the
trailing hour, with buckets at or over the fast burn threshold in red. The
axis starts where data starts, and clicking a bucket opens its bad events.
A definition panel below says what the SLO counts (source, eligible events
and filters, good events or the latency rule, objective) and when the
stored copy the list uses was last updated.

Stack

Part 23 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
  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 (this PR)
  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.

Screenshots or video

Before After
before, light after, charts and definition, light
after, dark

How to reproduce

Starting point: yarn dev on this branch (the pages need the API). .env.development turns on ENABLE_SLOS and NEXT_PUBLIC_ENABLE_SLOS (parts 7 and 14). Use a trace or log source with data; the demo server works.

On the previous part: the SLO page has stats only.

On this branch:

  1. On an SLO page, the SLI, budget and burn rate charts sit under the stats; the periods below the target and the overspent part are shaded, and buckets over the fast burn threshold are red.
  2. Click a bucket: its bad events open. The definition panel is at the bottom.

Test plan

  • states: while the history is loading, the charts show the shared time chart's loading state; when its query fails, each chart shows the error and the numbers above fall back to the stored copy
  • viewport: checked at 1440 px and in a narrow 900 px window. The list scrolls sideways and its toolbar wraps, the builder's preview moves under the form, and the SLO page's stats wrap to two columns.
  • app typecheck, lint and knip at this commit

How to test on Vercel preview

N/A: SLOs need the API, and the preview runs in local mode, where they are off.

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 27.

[no-story: allow] The new SLO components are page-level and fed by queries and form state, so this feature has no Storybook stories.

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

@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 7:01pm UTC
hyperdx-storybook Ready Ready Preview Nov 24, 2026 7:01pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

Duplicate code analysis

1 new clone introduced by this PR.

  • packages/api/src/routers/external-api/v2/alerts.ts:908-925 ↔ packages/api/src/routers/external-api/v2/alerts.ts:1181-1197 — 18 lines

If one of these duplicates a helper that already exists, import it instead
of redefining it. If the duplication is deliberate, ignore this comment —
the check is advisory and never fails the build.


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

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 477 passed • 1 skipped • 1148s

Status Count
✅ Passed 477
❌ Failed 0
⚠️ Flaky 11
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

Adds three charts to the SLO page over the window, from the same bucketed
query as the numbers above them, so both describe the same moment: the SLI
per bucket against the target, with the periods below it shaded; the error
budget left, with the overspent part shaded; and the burn rate over the
trailing hour, with buckets at or over the fast burn threshold in red. The
axis starts where data starts, and clicking a bucket opens its bad events.
A definition panel below says what the SLO counts (source, eligible events
and filters, good events or the latency rule, objective) and when the
stored copy the list uses was last updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alex-fedotyev
alex-fedotyev force-pushed the alex/HDX-3001-slo-23-app-charts branch from 741a52e to 2ebfd1a Compare November 24, 2026 18:58
@changeset-bot

changeset-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2ebfd1a

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

🟡 Tier 3 — Standard

Introduces new logic, modifies core functionality, or touches areas with non-trivial risk.

Why this tier:

  • Diff size: 511 production lines changed (Tier 2 max: < 250)

Review process: Full human review — logic, architecture, edge cases.
SLA: First-pass feedback within 1 business day.

Stats
  • Production files changed: 5
  • Production lines changed: 511
  • Branch: alex/HDX-3001-slo-23-app-charts
  • Author: alex-fedotyev

To override this classification, remove the review/tier-3 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 · 🟡 2 P2 · 🔵 2 P3

None could be anchored to changed lines; they are listed below. 2 P3 folded at the bottom.

Findings outside the changed lines

  • 🟡 P2 packages/app/src/components/Slos/SloCharts.tsx:306 — Memoizing lines (and useCallback for onBucketSelect) cannot keep the memoized charts stable → MemoChart is memo()'d, but every SloCharts render still passes it new props: referenceLines JSX, referenceLineValues arrays, belowTarget, common.onBucketClick, and the inline setIsClickActive in SloChart.tsx. So the memo never skips a render, and the useCallback in SloDetailPage.tsx:82 is wrapped by a fresh arrow anyway. Either memoize those props too (as useAlertReferenceLines does in alerts/AlertDetailChart.tsx), or drop the memo, the useCallback and the comment that claims stability.
  • 🟡 P2 packages/app/src/components/Slos/SloCharts.tsx:332 — Clicking a burn-rate bar opens one bucket's events, but the bar measures the trailing hour → On a 7d SLO the bucket is 30 minutes and the burn window is 1 hour, so a red bar's drill-down shows only half the events behind its value. For the burn chart, pass onBucketClick a range of [start + bucketMs - burnWindowMs, start + bucketMs].
🔵 2 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/components/Slos/SloChart.tsx:167 — Error text uses a raw color prop instead of the semantic Text variant → Use <Text size="xs" variant="danger" ta="center"> in place of c="var(--color-text-danger)". The conventions' "Semantic component variants" section says inline status text should use Text variant="danger".
  • 🔵 P3 packages/app/src/components/Slos/SloChart.tsx:55 — New chart logic has no tests → badPeriods (merging consecutive bad buckets, gaps between them), overspentZone (returns null when the budget never drops below zero), the burn/burn_high split at the threshold, and describeBucket are all untested; the only tests in Slos/tests cover the form and the list. Add unit tests for these pure helpers.

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

Three new SLO history charts (SLI vs target, error-budget burndown, burn rate) plus a Definition panel on the SLO detail page, fed by the existing bucketed-counts query. The core math is sound: badPeriods merges only truly-adjacent bad buckets, the burn/burn_high split is a complete partition with the boundary bucket landing in burn_high, overspentZone is empty-array safe, and Number(activeLabel) * 1000 operates on a finite seconds value. No correctness or data-integrity defect introduced. The findings below are a live-refresh UX regression, one defensive-hardening gap, and a test-coverage gap.

🟡 P2 -- recommended

  • packages/app/src/components/Slos/useSloLiveStatus.ts:54 -- Each 5-minute now tick shifts the window end and produces a new react-query key, and the query has no keepPreviousData, so all three charts drop to the loading/empty state and refetch from scratch on every tick instead of refreshing in place.
    • Fix: Pass placeholderData: keepPreviousData to the useQueriedChartConfig call in useSloHistory (and the burn query) so prior buckets stay rendered while the new range loads.
    • julik-frontend-races
  • packages/app/src/components/Slos/SloDetailPanels.tsx:188 -- formatDistanceToNowStrict(new Date(status.evaluatedAt)) is unguarded, so a non-parseable evaluatedAt throws synchronously during render and, with no error boundary around the panel, blanks the entire SLO detail page rather than degrading one line.
    • Fix: Validate the parsed date (Number.isNaN(d.getTime())) and render a fallback label before formatting, applying the same guard to windowEvaluatedAt and lastSuccessAt.
    • correctness, adversarial
  • packages/app/src/components/Slos/SloChart.tsx:49 -- The new pure helpers badPeriods and overspentZone and the burn/burn_high threshold split carry real branching logic but ship with no unit tests, so a regression in the merge, the >= threshold boundary, or the Math.min(..., 0) empty-array guard would go uncaught.
    • Fix: Add a __tests__/sloChart.test.ts covering badPeriods adjacent-vs-gap-separated runs, overspentZone empty/all-null/negative cases, and the exact-threshold burn classification.
    • testing, correctness, maintainability, kieran-typescript, project-standards, adversarial
🔵 P3 nitpicks (8)
  • packages/app/src/components/Slos/useSloLiveStatus.ts:49 -- getSloWindowRange does not floor its end to a bucket boundary (unlike getSloBurnQueryRange), so every 5-minute tick mints a never-reused cache key and nudges the x-axis bucket edges.
    • Fix: Floor the window end to the history granularity before building the range so the key changes only when a bucket actually completes.
  • packages/app/src/components/Slos/SloCharts.tsx:98 -- The lines useMemo has empty deps but reads theme colors via getChartColor*() at mount, so a light/dark toggle leaves series colors stale while the inline reference-line colors update, drifting the two apart.
    • Fix: Add the active theme (or the resolved color tuple) to the dependency array, or document the remount requirement.
    • maintainability, kieran-typescript, project-standards
  • packages/app/src/components/Slos/SloDetailPanels.tsx:156 -- key={describeFilter(filter)} collides when two filters stringify identically, producing a React duplicate-key warning.
    • Fix: Include the map index in the key, e.g. key={${i}-${describeFilter(filter)}}.
  • packages/app/src/components/Slos/SloCharts.tsx:155 -- The threshold value is passed twice per chart (once to draw the line, once in referenceLineValues for the axis domain), so the two props must be kept in sync by hand.
    • Fix: Derive the axis-domain values from the same source that builds the reference elements, or have SloChart accept one threshold descriptor.
  • packages/app/src/components/Slos/SloChart.tsx:93 -- y1={lowest * 10} uses a bare multiplier to push the overspent band below the axis floor, with no name for the intent.
    • Fix: Extract a named constant documenting the clip-to-floor overshoot.
  • packages/app/src/components/Slos/SloDetailPanels.tsx:164 -- The "Good events" and status blocks nest template/latency/requireDuration conditionals and chained ternaries inline with the markup, obscuring the branch logic.
    • Fix: Extract the sentence-building into pure helpers (e.g. describeGoodEvents, describeStatusFreshness) alongside the existing sloUtils formatters.
    • maintainability, testing
  • packages/app/src/components/Slos/SloCharts.tsx:51 -- For a 7d SLO the leftmost burn-rate bucket is computed over a single 30-minute bucket yet labeled as a trailing-1h rate, so the first bar can read slightly high or low.
    • Fix: Consider dimming or omitting burn-rate buckets whose trailing window is not yet full.
    • adversarial
  • packages/app/src/components/Slos/SloCharts.tsx:1 -- No @hyperdx/app changeset accompanies this user-facing app feature; this may be an intentional stack-wide consolidation.
    • Fix: Confirm the app version bump is captured by a changeset elsewhere in the stack, or add one.
    • project-standards

Reviewers (9): correctness, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, adversarial, agent-native, learnings-researcher.

Testing gaps:

  • No unit tests for badPeriods, overspentZone, or the burn/burn_high boundary classification (new pure logic).
  • No test advances a fake timer past the 5-minute refresh to assert the charts do not flash to empty on a live tick.
  • No render test for SloDefinitionPanel branches (latency vs good, filters, and malformed/missing status dates).

Notes: agent-native found no blocking parity gap — all new surfaces map to existing SLO MCP tools except the per-bucket history series, which an agent can reconstruct from clickstack_get_slo's definition (optional enhancement, pre-existing). learnings-researcher found no applicable prior learnings. The 4 prior PR comments are all automated bot output (Vercel, jscpd, e2e, changeset) with no code feedback against this diff, and the jscpd clone it reports is in packages/api files outside this diff, so no previous-comments verification was warranted.

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-storybook — 2ebfd1a5 Deployed Nov 24, 2026 by vercel[bot]
Preview – hyperdx-oss — 2ebfd1a5 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-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant