Skip to content

feat(app): eligible-event filters and the latency template in the builder - #3805

Open
alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-17-app-builder-objectivefrom
alex/HDX-3001-slo-18-app-filters-latency
Open

alex-fedotyev wants to merge 1 commit into
alex/HDX-3001-slo-17-app-builder-objectivefrom
alex/HDX-3001-slo-18-app-filters-latency

Conversation

@alex-fedotyev

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

Copy link
Copy Markdown
Contributor

Summary

The eligible events in the SLO builder can now carry filters, shown and
edited with Search's own filter pills; filters the pills cannot show, such
as raw SQL, stay as written. The builder also gets a type switch between
availability and latency. A latency SLO counts an event as good when its
duration is within a threshold in milliseconds: the duration starts from
a trace source's duration column, in the unit of its precision, and any
other column or attribute can be used with the unit it holds, cast to a
number. Events without a duration are left out, or counted as bad.

Stack

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

Screenshots or video

Before After
before, light after, the latency template, light
after, dark
after, filter pills, light

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: availability only, and filters are not shown.

On this branch:

  1. Switch Type to Latency with a trace source: the duration starts from its Duration column, in the unit of its precision.
  2. Edit an SLO whose eligible events have filters (one made from a search): they show as Search's pills.

Test plan

  • unit: sloForm.test.ts
  • 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.

[ui-states: allow] No new empty, loading or error states here beyond the ones listed above.

[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

@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 472be76

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

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.10%).
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 • 475 passed • 1 skipped • 1209s

Status Count
✅ Passed 475
❌ Failed 0
⚠️ Flaky 13
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

…lder

The eligible events in the SLO builder can now carry filters, shown and
edited with Search's own filter pills; filters the pills cannot show, such
as raw SQL, stay as written. The builder also gets a type switch between
availability and latency. A latency SLO counts an event as good when its
duration is within a threshold in milliseconds: the duration starts from
a trace source's duration column, in the unit of its precision, and any
other column or attribute can be used with the unit it holds, cast to a
number. Events without a duration are left out, or counted as bad.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alex-fedotyev
alex-fedotyev force-pushed the alex/HDX-3001-slo-18-app-filters-latency branch from 55f928e to 472be76 Compare November 24, 2026 18:58
@alex-fedotyev
alex-fedotyev marked this pull request as ready for review November 24, 2026 21:30
@alex-fedotyev
alex-fedotyev requested a review from a team as a code owner November 24, 2026 21:30
@github-actions github-actions Bot added the review/tier-3 Standard — full human review required label Nov 24, 2026
@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: 409 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: 4
  • Production lines changed: 409 (+ 2 in test files, excluded from tier calculation)
  • Branch: alex/HDX-3001-slo-18-app-filters-latency
  • 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): 🔴 1 P0/P1 · 🟡 2 P2 · 🔵 1 P3

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

Findings outside the changed lines

  • 🔴 P1 packages/app/src/components/Slos/SloEligibleFilters.tsx:155 — isRawSloFilter treats a partly parsed filter as a pill filter, so editing any pill silently drops part of the eligible condition → isRawSloFilter only checks that parseQuery returns an empty state. That is the loose check that isRenderablePinnedFilter's doc in packages/common-utils/src/filters.ts:622-667 warns against. Take a saved filter like ServiceName IN ('checkout') AND StatusCode = 'Error': parseQuery pulls out the IN clause, so the filter counts as not raw. It gets no raw <Code> row, and the pill shows only ServiceName = checkout. When the user toggles, replaces or removes any pill, updateFilterQuery in searchFilters.tsx:169 rebuilds the list from the parsed state plus the preserved filters, so AND StatusCode = 'Error' is lost and the eligible set silently gets wider. The same happens with x NOT BETWEEN 1 AND 2, which parses to key x NOT and shows the inverse range. Fix: use isRenderablePinnedFilter from @hyperdx/common-utils/dist/filters instead of the hand-rolled helper (isPreservedFilter: f => !isRenderablePinnedFilter(f)). Also give useSearchPageFilterState only the renderable filters as searchQuery. Otherwise a raw filter that partly parses is still read into the pill state and saved twice (see the isPreservedFilter doc in searchFilters.tsx:115-122).
  • 🟡 P2 packages/app/src/components/Slos/SloLatencyFields.tsx:438 — Clearing the threshold input forces it back to 0, so the user cannot clear the field to type a new value → onChange={v => field.onChange(typeof v === 'number' ? v : 0)} turns the empty string Mantine sends on clear into 0. The controlled input then shows 0 ms straight away, and typing after it gives 05. The good-SQL preview also shows <= 0. Fix: store undefined (or keep the string) when v === '' and let thresholdMs: z.number().positive() report the empty field. For example, field.onChange(typeof v === 'number' ? v : undefined), with the form type allowing an empty value.
  • 🟡 P2 packages/app/src/components/Slos/__tests__/sloForm.test.ts:463 — The new filter split and the duration reset when the source changes have no tests → The only test change adds filters: [] to an expected object. Nothing tests isRawSloFilter and how filters are split between pills and raw rows, including the compound-filter case above. Nothing tests the SloLatencyFields effect either: it should replace the source's own duration column when the source changes but keep a typed expression. Add unit tests for the filter predicate (simple IN, compound IN ... AND x = 1, NOT BETWEEN, sql_ast). Also add a render test showing that switching sources replaces only the native duration expression.
🔵 1 P3 — no action needed before merge
  • 🔵 P3 packages/app/src/components/Slos/SloLatencyFields.tsx:385 — field.value ?? true guards a value that is never undefined, and the description ignores the fallback anyway → requireDuration is a required boolean in the form type: SloLatencySchema gives it .default(true), and DEFAULT_LATENCY sets it. So the ?? true fallback is dead code. If it ever did apply, the description, which reads field.value directly, would say events "count as bad" while the box shows as checked. Fix: drop the fallback and use checked={field.value}, so the checkbox and its description read the same value.

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. No P0/P1 ship-blockers surfaced: the change is a self-contained, flag-gated frontend addition (NEXT_PUBLIC_ENABLE_SLOS), the form→API mapping round-trips through the same SloInput schema the MCP tools accept (agent-native parity holds), and the latency unit/numeric logic is covered by sloForm.test.ts. The items below are recommended follow-ups, not merge blockers.

🟡 P2 — recommended

  • packages/app/src/components/Slos/SloEligibleFilters.tsx:29 — isRawSloFilter classifies a filter as renderable whenever parseQuery([filter]).filters is non-empty, but parseQuery is lenient: a compound pinned filter such as col IN ('x') AND foo = 1 parses to a single facet while the AND foo = 1 conjunct is dropped, so it renders as a partial pill and, because it is not preserved, editing any pill re-emits only the parsed facets and silently drops the extra conjunct from the saved eligible filters — changing which events the SLI counts.
    • Fix: Define isRawSloFilter as the negation of the existing isRenderablePinnedFilter from @hyperdx/common-utils/dist/filters so only fully-renderable single-facet filters become pills and everything else is preserved verbatim.
    • maintainability (corroborated the catch-all behavior)
  • packages/app/src/components/Slos/SloEligibleFilters.tsx:28 — the new file's only non-trivial logic (raw-vs-facet classification, the raw-filter list, describeFilter-keyed rendering, and CloseButton removal) ships with no test.
    • Fix: Export isRawSloFilter and unit-test the single-facet, compound, raw-SQL, and parse-throw cases, plus a render test for raw-filter listing and removal.
    • testing, maintainability
  • packages/app/src/components/Slos/sloForm.ts:57 — the new eligible.filters ?? [] fallback in sloToFormValues is never exercised because the only sloToFormValues test feeds a saved SLO that already carries filters.
    • Fix: Add a case loading a saved SLO whose eligible omits filters and assert the form receives filters: [].
    • testing
🔵 P3 nitpicks (5)
  • packages/app/src/components/Slos/SloEligibleFilters.tsx:116 — describeFilter(filter) is used as the React key for raw filters, so two raw filters with identical rendered text collide on key.
    • Fix: Key by array index or a stable id rather than the display string.
  • packages/app/src/components/Slos/SloLatencyFields.tsx:68 — switching from a trace source (native duration) to a source without one resets indicator.latency.expression to '' but only updates indicator.latency.unit when the new source has a duration, leaving the previous source's unit stale in the enabled, now-non-native Select.
    • Fix: Reset the unit alongside the expression when the new source has no native duration, or fall back to a default unit.
  • packages/app/src/components/Slos/sloForm.ts:80 — getNativeDuration with an undefined source and requireDuration (both true and false) are not asserted end-to-end through toSloInput.
    • Fix: Add toSloInput(latency('Duration')) (no source) asserting numeric: false, and assert requireDuration survives for both values.
  • packages/app/src/components/Slos/SloLatencyFields.tsx:68 — the seed-from-source effect (nativeDurationRef) duplicates the near-identical availability-seeding effect in SloDefinitionFields.tsx:64, with the "replace only a seeded value" invariant implemented twice.
    • Fix: Extract a shared useSeededFromSource hook, or cross-reference the two sites so the invariant stays in sync.
    • maintainability
  • packages/app/src/components/Slos/SloEligibleFilters.tsx:29 — the catch { return true } conflates a genuinely malformed filter with an intentionally-raw one, silently showing broken filters as Code chips.
    • Fix: Add a comment distinguishing the two cases, or handle a parse failure distinctly.
    • maintainability

Reviewers (6 returned): testing, maintainability, project-standards, agent-native, learnings-researcher, previous-comments. Correctness, adversarial, kieran-typescript, and julik-frontend-races were dispatched but had not returned at synthesis time — the findings above include the orchestrator's own full read of all five changed files and hands-on verification of the filter-classification, unit, and seeding logic, but the deep correctness/race pass is incomplete.

Testing gaps:

  • Component behavior in SloEligibleFilters.tsx (facet-vs-raw split, empty-filters early return, raw-filter removal) is untested.
  • The SloLatencyFields source-seeding effect's non-clobber invariant (replace a seeded duration, preserve a user-typed one) and the native-vs-cast unit disabling are untested.
  • The SloDefinitionFields availability/latency template switch and good-condition seeding effect are untested.
  • Prior PR comments were all automated bots (Vercel, changeset, jscpd, e2e); the jscpd clone it cites is in packages/api/.../alerts.ts, out of this diff's scope — nothing to address.

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 — 472be762 Deployed Nov 24, 2026 by vercel[bot]
Preview – hyperdx-oss — 472be762 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