Repository navigation
feat(app): add a duration heatmap view to trace search - #3184
alex-fedotyev wants to merge 15 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 7e7a232 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
| // (undefined -> id) doesn't count as a change and a shared link that pins | ||
| // ?traceChartMode=heatmap survives. | ||
| const prevSourceIdRef = useRef<string | undefined>(undefined); | ||
| useEffect(() => { |
There was a problem hiding this comment.
🔵 minor — Reset effect discards the user's Heatmap choice even when the new source can render it
The effect fires on any searchedSource?.id change, so switching from trace source A to trace source B — both with a durationExpression, so both render the toggle via traceRedMetricsSource — silently flips the view back to RED. The sibling view toggle analysisMode (:1067) is deliberately not reset on source change even though delta needs a trace source too; that branch just renders nothing (:2637). Drop the effect (both the switch and the chart are already hidden when traceRedMetricsSource == null, so a lingering ?traceChartMode=heatmap is inert), or gate the reset on the new source not supporting the heatmap.
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
There was a problem hiding this comment.
Keeping a reset, but since 364e04c and 8c2175f it only runs for a source the user picks, not on every source id change. A lingering ?traceChartMode=heatmap isn't inert: coming back to a trace source would reopen the heatmap and switch live tail off again. Back/Forward keeps whatever mode the URL restores.
PR Review
4 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 3 P3 No inline comments. 2 P3 folded at the bottom. 2 unchanged from an earlier push (already inline above). 🔵 2 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. This is a small, heavily-iterated frontend change (~228 production lines) that adds a URL-backed RED/Heatmap toggle to the trace search results view. The two extracted hooks are correct and unit-tested, the live-tail guard effect converges without a render loop, the mode-reset arm/disarm logic is sound, and the chart branch, switch, and live-tail pin all read one derived 🟡 P2 -- recommended
🔵 P3 nitpicks (2)
Reviewers (10): correctness, adversarial, frontend-races, kieran-typescript, testing, maintainability, project-standards, previous-comments, agent-native, learnings-researcher. 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 |
e19f185 to
f73ecf0
Compare
| // can't disable live tail for a search that shows the histogram. | ||
| const isHeatmapChartVisible = | ||
| analysisMode === 'results' && | ||
| traceRedMetricsSource != null && |
There was a problem hiding this comment.
🔵 minor — Switching back to RED leaves live tail off
The pin writes isLive=false into the URL, and nothing restores it. A user who looks at the heatmap for a moment and switches back to RED is left on a frozen time range with live tail off. Pausing live updates through useLiveUpdate's pause while the heatmap is visible, instead of overwriting isLive, would bring live tail back when the user switches to RED.
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
There was a problem hiding this comment.
Intended: delta and pattern modes turn live tail off the same way, and pausing instead would leave the TimePicker and the results count claiming live tail over a frozen range. Back on RED, Resume Live Tail brings it back in one click.
ce233e9 to
46b3d9e
Compare
…3221) ## Summary Fixes the heatmap part of #3205: during a dashboard refresh, heatmap tiles now keep the current heatmap on screen and pulse, instead of replacing it with "Loading...". - Both heatmap queries (the min/max bounds and the buckets) keep their previous result as placeholder data, the same way the time chart and the number, bar and pie tiles do. - The bucket query waits for the refreshed bounds before it runs, so a refresh doesn't also query the new range bucketed with the previous range's min/max. - The heatmap, and the "Not enough data points" message, pulse while either query is still showing previous data. `Heatmap` takes an optional `className` so the pulse goes on its existing container rather than a new wrapper, which would affect its size measurement. - New tests in `DBHeatmapChart.render.test.tsx`: both queries keep their previous data, the tile pulses during a refresh and stops once fresh data loads, and the bucket query waits for fresh bounds. Three of the four fail without the change. While checking the rest of the app for the same pattern, I found two more places: the Kubernetes dashboard's Pods, Nodes and Namespaces tables still switch to skeleton rows on every refresh, and the Services dashboard tiles (`DBListBarChart`, `DBHistogramChart`, the slowest events tile) keep their data but don't pulse. Happy to take those as follow-ups if you'd like. ### How to test on Vercel preview **Preview routes:** /dashboards **Steps:** 1. Create a dashboard with a Heatmap tile on the demo traces source (for example on `Duration`) and a Line time chart. 2. Choose a large time range so each query takes a moment. 3. Click "Refresh dashboard". 4. Verify the heatmap stays on screen and pulses while its queries run, like the line chart, and stops pulsing once the new heatmap appears. ### References - Linear Issue: N/A - Related PRs: #3211, #3212. #3184 also edits the `queryKey` of these two heatmap queries, so whichever lands second needs a small rebase. - Closes part of #3205 Checks run locally: `jest` for the heatmap suites and `ChartPreviewPanel` (50 passed), `eslint` on changed files (0 errors, no new warnings), `prettier --check`, and `tsc --noEmit` for `packages/app`.
46b3d9e to
5809452
Compare
E2E Test Results✅ All tests passed • 476 passed • 1 skipped • 1160s
Tests ran across 4 shards in parallel. |
860924c to
43d41de
Compare
Adds a RED/Heatmap switch to the trace results chart area. Heatmap renders the duration distribution over time as the same tile the dashboard does. The mode is URL state, so a reload or a shared link reopens the same view, and it resets to RED when the source changes. The heatmap's bounds and bucket queries take the search's RED query-key prefix (DBHeatmapChart gains the queryKeyPrefix prop DBTimeChart already has; keys are unchanged for callers that don't pass one), so live tail waits on them instead of stacking a fresh pair each tick. Live tail is also pinned off while the heatmap is the visible chart: a tick moves the absolute time range, and the heatmap keys its uPlot instance on the chart config, so each refresh would otherwise tear the chart down and rebuild it. The switch, the chart branch and the live-tail pin share one derived source, so the heatmap renders (and pins live tail) only where the RED tiles would: a trace source with a duration column, a non-compact viewport, and no custom group-by. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The live-tail pin only ran when the heatmap first appeared, so Resume Live Tail (or the TimePicker's Live option) turned live tail back on while the heatmap was still showing, and every tick rebuilt the chart. - Hide the TimePicker's Live option and the Resume Live Tail button while the heatmap is the visible chart, the way delta and pattern modes hide them, and make the guard check isLive so any other path that turns live tail on (a relative range pick) is switched off again. - Move the source-change reset and the live-tail guard into useTraceChartModeGuards, with tests for first load, a real source switch, and resuming live tail under the heatmap. - Drop the @source tag on the heatmap query in favor of a plain note, and document that queryKeyPrefix only applies to distribution heatmaps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nuqs 1.x writes an explicitly set default into the URL, so resetting the trace chart mode with 'red' added ?traceChartMode=red on every source switch, log sources included. Clear the param instead; the mode still falls back to RED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mode union lived in TraceRedMetricsChart and a hand-written copy in the URL parser, so a mode added to the type alone would compile but parse back to RED. Export TRACE_CHART_MODES, derive TraceChartMode from it, and use it in the parser and the view switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The prefix let live tail wait on the heatmap queries, but live tail is always off while the heatmap is the visible chart, so it never changed anything. It did give these queries different keys from the identical delta-view heatmap. Without it, DBHeatmapChart and useHeatmapData go back to their current shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reset ran in an effect on the searched source id, so it also fired when Back or Forward restored a URL with traceChartMode=heatmap, and rewrote that history entry back to RED. Clear the mode in the page's existing user-source-change branch instead, which catch-up (history navigation, a source name resolving) already skips. The hook keeps only the live-tail guard, renamed useHeatmapLiveTailGuard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clearing the mode from the dropdown branch ran before the debounced search submit pushed the new source, so it rewrote the previous history entry, and Back still landed on RED. Mark the reset as pending there, like the filter and group-by reconciles, and clear the mode once the URL points at the new source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The heatmap config carried the results table's orderBy. The heatmap's own queries don't use it, but the chart keys its uPlot instance on the config, so sorting a column tore the heatmap down and rebuilt it. Drop the sort from the base config, as the histogram config does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The heatmap doesn't group, but the picker stayed in the stats row, and picking a custom group-by swapped the heatmap and the RED/Heatmap switch for the histogram with no hint why. Hide the picker while the heatmap is the visible chart; it comes back on the RED view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Picking a source arms a reset that fires once the URL points at it. If the user re-selected the searched source before that search ran, the reset stayed armed for the abandoned source, so a later navigation to it with traceChartMode=heatmap cleared the mode it meant to restore. Clear it whenever the form catches up to the searched source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isHeatmapChartVisible ignored the chart branch's other conditions, so while the chart config was resolving or a query error hid the chart area, it still kept live tail off and hid the Live option, Resume Live Tail and the group-by picker. Derive it from the same conditions the chart branch uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reset that clears traceChartMode after a source pick lived inline in DBSearchPage as a ref and an effect, with no tests, and it needed several follow-up fixes. Move it into useTraceChartModeReset, which the page arms on a user pick and disarms when the pick is undone, and test the cases those fixes were about: it fires only once the searched source reaches the pick, once per pick, never for Back/Forward, not after an undone pick, and for the latest pick. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Condense the comments this PR adds to the reasons a reader needs, and restore one comment it had reworded. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The source-change reset already clears the param because nuqs 1.x writes an explicitly set default into the URL, but choosing RED in the switch still wrote traceChartMode=red into the URL and shared links. Clear it there too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Render the component in each mode with the chart components stubbed and the real query builder kept: heatmap mode mounts the heatmap, not the tiles, with the duration-in-ms value, count(), a log scale and the duration number format; RED mode mounts the three tiles, and only Duration opts into its pinned colors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43d41de to
7e7a232
Compare
Stack
Layer 2 of 2 in a GitHub stack (stack #3688). GitHub shows this PR's base as
alex/red-metrics-trace-search-v2, the branch below it, but the stack's base ismain: merging this PR lands it and #3183 onmain, one squashed commit each. Its diff is only the heatmap layer, and CI runs as if it targetsmain:Summary
Adds a RED/Heatmap switch to the trace search results view. Heatmap replaces the three RED tiles with the duration distribution over time, as the same bare heatmap tile the dashboard renders (
DBHeatmapChartwith atoHeatmapQueryquery), without the significant-fields comparison panel.traceChartMode, like the other view toggles on this page, so a reload, a shared link, or Back/Forward reopens the same view. Picking a different source in the dropdown resets it to RED, so returning to a trace source after viewing another one doesn't silently reopen in Heatmap and switch live tail off again. The reset waits until the URL points at the new source, like the page's filter and group-by reconciles, so it lands on the new history entry, and it clears the param rather than writingredinto every URL. It lives inuseTraceChartModeReset.getDurationMsExpression(the source's duration scaled to ms by itsdurationPrecision) with the existingHEATMAP_DURATION_NUMBER_FORMAT, the same pairing the delta-view heatmap uses. Value, count and scale are fixed rather than read from that view's settings drawer, so this stays a plain duration heatmap independent of the delta view's query state.DBHeatmapChartis used as is. The heatmap needs no query namespace of its own: live tail is off whenever it shows, so no tick can stack its queries.useHeatmapLiveTailGuard.?traceChartMode=heatmapcan't disable live tail on a search that shows the histogram.Screenshots
Light theme:
Dark theme:
Test plan
useHeatmapLiveTailGuardtests cover the guard: off when the heatmap appears, off again when resumed under it, untouched on RED.useTraceChartModeResettests cover the source-change reset: it waits for the URL to reach the picked source, fires once per pick, ignores Back/Forward, drops an undone pick, and follows the latest pick.TraceRedMetricsChartrender tests: heatmap mode mounts the heatmap, not the tiles, with the duration-in-ms value,count(), a log scale and the duration number format; RED mode mounts the three tiles, and only Duration pins its colors.tsc --noEmit,eslintwith no new warnings, knip, and thetraceRedMetrics,DBTimeChartandDBSearchPagesuites green against currentmain.traceChartMode, coming back to traces resets to RED, and Back from Logs returns to the heatmap (as do Forward and Back after it); a custom group-by and a compact (390px) viewport fall back to the histogram with the switch hidden. The heatmap shows Loading while its queries are in flight and "Not enough data points" for a WHERE that matches nothing, and a failed search query hides the chart area and shows the query error, with the Live option, Resume Live Tail and the group-by picker available again.Notes
minorchangeset.mainindependently in refactor: Decompose heatmap query and view builders #3276 (HEATMAP_DURATION_NUMBER_FORMAT), which this uses.