Repository navigation
Conversation
DBSearchPage's Results Table view shows scanned rows/elapsed time next to the results, but when viewing a single trace (directTraceId set) there is no glanceable total wall-clock duration or span count for that trace -- users have to open the trace waterfall to see it (#3038). Adds useTraceTotalDuration, which issues a small aggregate query (MIN/MAX/COUNT over the trace's spans) using the resolved source's timestamp/duration/traceId expressions, mirroring the existing DBTraceWaterfallChart getConfig pattern for embedding the traceId (SqlString.escape) into a raw SQL where clause. Renders as a TraceTotalDurationStat next to SearchNumRows.
Addresses the changeset-bot note on #3051 so this user-visible Search stats-row addition is included in the next @hyperdx/app version bump.
…aterfall view Move the #3038 stat out of DBSearchPage's Results Table (where the displayed rows/spans can diverge from the actual trace scope once the user edits the search -- a bad place for a "total trace duration" figure to live) and into DBTraceWaterfallChartContainer instead, where the trace's full span set is already fetched for the waterfall itself. Computes MIN(start)/MAX(start+duration)/span count directly from the already-fetched `rows` (client-side, no extra query), consistent with how the waterfall bars already compute each span's own offset/duration (parseTimestampToMs + Duration*1000). Only counts spans, not correlated logs. Renders next to the existing "N spans, N errors" text in the waterfall controls bar. Reverts the earlier DBSearchPage.tsx placement and removes the now-unused useTraceTotalDuration hook/query.
- Drop the span count from the new stat -- it duplicated the existing "N spans, N errors" text with a different scope (all fetched spans vs. the visible/toggled subset), producing contradictory lines like "0 spans, 1 error · Total Duration: 2.28s · 12 spans" once the user toggles a chip or applies a filter. Fold the stat into the same <Text> as the existing count instead of a separate floating element. - Rename "Total Duration" to "Total duration" (sentence case, per AGENTS.md UI text convention); update matching test assertions. - Surface the trace query's 50k-row-per-window cap: propagate an `isTruncated` flag from useEventsAroundFocus through useFilteredEventsAroundFocus into the container, and append a "+" to the displayed duration when either window hit the cap, instead of silently presenting a partial total as exact. - Add tests: log exclusion no longer relies on a same-timestamp log row (uses a log timestamped an hour later, which would blow up the reported duration if wrongly included); overlapping-spans case where the true MAX(end) span is not the last one processed (catches a "last write wins" bug the non-overlapping fixture couldn't); chip toggling doesn't change the stat (proves it reflects all fetched spans, not the visible subset); isTruncated flagging via a cheap length-only mock in useEventsAroundFocus rather than a real 50k-row render (which timed out in jsdom).
Fetch one extra waterfall row so a complete window of exactly 50,000 spans is not marked truncated. Compute duration from span rows only, drop the unused spanCount field, document wall-clock vs MCP, and explain the lower-bound marker with a tooltip.
…k on trace total duration - Fix TS2339: traceRowsData's static row type doesn't expose Duration (useEventsAroundFocus builds it via an object-literal spread of an any-typed ClickHouse row plus explicit re-declared keys, so TS infers the element type from only the explicit keys). Cast to any[] for the loop, matching the existing any-typed access pattern used elsewhere in this file (rows.reduce, visibleNodes.map) for the same dynamic shape. - Extend the lower-bound/truncation marker to also fire when the +/-1h dateRange fetch window itself clips the trace (a span starting at/before the window's lower edge, or ending at/after its upper edge), not just the TRACE_WATERFALL_ROW_LIMIT row cap. Previously a trace clipped by the focus window reported a confident-looking exact duration with no indication data was missing. Generalize the tooltip copy to cover both triggers. - Add tests for the new window-edge behavior (lower edge, upper edge, and the not-clipped case), run through the full render chain. - Widen the test file's shared mockDateRange/mockFocusDate, which never actually overlapped the mock span/log timestamps used by the existing duration tests (harmless before this change, since nothing previously compared row timestamps against dateRange) so the new window-edge check doesn't spuriously trip on unrelated tests.
…ration-in-search-table
The row type dropped Duration after spreading a Record, and comparing the earliest start to the window start never sees an earlier span. Treat a missing parent on the earliest span, or a span that runs to the window end, as a lower bound, and keep trimmed query windows stable across renders.
…rent A parent that was never exported is a gap in the trace when the child starts inside the fetch window, and an empty parent id is a real root. The lower-bound marker now follows a start pressed against the window, or a span that runs to the window end. Co-authored-by: Cursor <cursoragent@cursor.com>
The 1ms window-edge tolerance missed a root that started before the window and flagged a span that only started on the edge. A parent id on the earliest loaded span that was not fetched is the start clip.
🦋 Changeset detectedLatest commit: 4cb4f62 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
|
| if (startMs < minStartMs) { | ||
| minStartMs = startMs; | ||
|
|
||
| // The start is clipped if the earliest span has a parent that was not fetched | ||
| const parentId = | ||
| typeof row.ParentSpanId === 'string' ? row.ParentSpanId : ''; | ||
| isStartClipped = parentId.length > 0 && !validSpanIDs.has(parentId); | ||
| } |
There was a problem hiding this comment.
Missing ancestor goes unmarked
If the earliest fetched span is a root but a later span's parent started before the selected time range, this code never checks the later span's missing parent. The displayed duration omits that earlier work but has no + marker, so an incomplete trace appears to have an exact duration.
Knowledge Base Used: Trace investigation
| } | ||
|
|
||
| if (endMs > maxEndMs) maxEndMs = endMs; | ||
| if (endMs >= windowEndMs) isEndClipped = true; |
There was a problem hiding this comment.
Complete trace marked incomplete
A span ending at or after the selected range's upper edge sets the + marker even when every span was fetched. Ending at that edge does not establish that the trace is incomplete, so users can be told a complete duration is only a lower bound.
Knowledge Base Used: Trace investigation
|
|
||
| // Stable empty fallback. `data ?? []` would allocate a new array every render | ||
| // and invalidate every memo downstream of the waterfall rows. | ||
| const EMPTY_ROWS: Record<string, any>[] = []; |
There was a problem hiding this comment.
The new EMPTY_ROWS declaration uses Record<string, any>[], which discards type checks for rows passed downstream. The repository's code-style directive says to avoid any and use proper typing; this requirement needs to be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
E2E Test Results✅ All tests passed • 393 passed • 1 skipped • 1127s
Tests ran across 4 shards in parallel. |
Summary
Screenshots or video
How to test on Vercel preview
Preview routes:
Steps:
References