Trace investigation
Trace investigation helps an engineer move from a telemetry record to the full distributed request that produced it. The experience joins spans, related logs, exceptions, service context, and linked traces so that timing, errors, and cross-service work can be examined in one navigable view. It is a child of Explorer and query experience and relates to Search and log exploration, Session replay and exploration, Metric exploration, and External interfaces and automation.
Investigation model
Trace investigation treats a trace as a connected set of work rather than as one flat event. A trace source defines how trace IDs, span IDs, parent links, timing, service names, status, attributes, events, and links are read. Related log, session, and metric sources add context when they share the configured correlation fields.
Signal relationships
The trace ID is the main join point for a distributed request. Parent and span IDs describe the request tree, while source links let an engineer move to another trace when the work crosses an asynchronous or otherwise separate boundary.
The product uses configured source relationships instead of assuming that every data set has the same column names. This lets one trace view work with different telemetry schemas while preserving the same investigation path.
This diagram shows how an engineer moves from an initial record through trace structure and related signals.
flowchart LR
A[Log or span record] --> B[Trace ID]
B --> C[Trace waterfall]
C --> D[Span detail]
C --> E[Correlated logs]
D --> F[Exceptions and stack frames]
D --> G[Span links]
G --> C
B --> H[Service and session context]
References: packages/…/TraceTableModelForm.tsx• L169-243 packages/…/correlationFields.ts• L73-108 packages/…/source.ts• L184-235
Trace navigation
Trace navigation keeps the time range, selected source, trace ID, and selected row together as the engineer changes views. A trace can open from search, from a log record, from a direct URL, or from another trace through a span link.
Trace entry points
The search experience opens a trace in a wide side panel after the engineer selects a trace source. A log record with trace context offers a direct View Trace action. A direct /trace/<trace-id> address is normalized into the search experience, which allows the same source selection, not-found state, and trace inspection flow to handle shared links.
The trace source remains selectable at the point of entry. A direct trace link can start without a source, then apply the trace filter when a valid source becomes available. Source names in shared search links are resolved to source IDs without discarding the other query settings. If a source is missing or cannot load, the panel reports that state instead of treating an absent result as an empty trace.
References: packages/…/DirectTraceSidePanel.tsx• L25-100 packages/…/DirectTraceSidePanel.tsx• L102-160 packages/…/ViewTraceCalloutButton.tsx• L24-41 packages/…/[traceId].tsx• L8-39 packages/…/directTrace.ts• L10-22 packages/…/DBSearchPage.directTrace.test.tsx• L308-346 packages/…/DBSearchPage.directTrace.test.tsx• L398-532
Trace waterfall
The trace waterfall presents spans as a parent-child tree with time bars. The tree shows service and operation names, duration, status, warnings, span events, and related log rows on one time axis. Span rows use stable service colors, while correlated logs and error states use distinct visual cues. An engineer can expand or collapse branches, expand or collapse by depth, hide spans or logs, show or hide span events, and use a minimap to move through a large trace.
The view tolerates incomplete trace data. Missing parents can produce several roots, and a trace can contain logs without visible spans. These cases keep available records useful without claiming that the displayed tree is a complete causal path. The total duration is the wall-clock range covered by fetched spans. A plus marker identifies a lower bound when the time window clips the trace, a parent is missing, or the row cap clips the result.
Span and log filters run against their own sources and remain independent. An invalid filter falls back to the unfiltered data for that source and reports the error beside its input. A failure to load correlated logs does not blank a valid span waterfall. Filtered rows can disappear from the display while their descendants remain available for tree navigation.
References: packages/…/DBTraceWaterfallChart.tsx• L115-168 packages/…/DBTraceWaterfallChart.tsx• L454-521 packages/…/DBTraceWaterfallChart.tsx• L529-557 packages/…/DBTraceWaterfallChart.tsx• L845-899 packages/…/DBTraceWaterfallChart.tsx• L989-1133 packages/…/DBTraceWaterfallChart.tsx• L1166-1382 packages/…/DBTraceWaterfallChart.tsx• L1393-1677
Span detail views
Selecting a span opens its record beside the waterfall or below it. The detail view gives the engineer three levels of context: an overview of standard and custom fields, the source columns, and infrastructure data when the span carries Kubernetes context.
The trace panel keeps the selected span tied to the current trace. A selection restored from a shared URL cannot silently appear against a different trace. This prevents a stale row choice from producing misleading detail data.
References: packages/…/DBTracePanel.tsx• L82-120 packages/…/DBTracePanel.tsx• L301-356 packages/…/DBTracePanel.tsx• L454-535 packages/…/DBRowOverviewPanel.tsx• L82-119 packages/…/DBRowOverviewPanel.tsx• L275-343
Cross-signal navigation
Cross-signal navigation lets an engineer keep the current investigation while moving between data types. Source configuration supplies the links between trace, log, session, and metric records. The side panel keeps those hops in a breadcrumb trail so the engineer can return to the record that supplied the context.
Correlated logs
Correlated logs are log rows with the same trace ID as the selected trace. When a log source is configured, the waterfall places those rows beside the spans and attaches each row to its span ID when possible. This connects a request's timing to messages and severity changes without requiring a second search.
The trace and log filters are separate because they query separate sources. A filter error on the log side does not remove valid spans from the waterfall. It reports the log problem while preserving the primary trace view.
References: packages/…/TraceTableModelForm.tsx• L225-243 packages/…/DBTracePanel.tsx• L286-297 packages/…/DBTraceWaterfallChart.tsx• L782-823 packages/…/DBTraceWaterfallChart.tsx• L1453-1531 packages/…/waterfall.ts• L658-753
Span links
A span link is a reference from one span to a span in another trace. The span detail overview shows valid outgoing links with their trace ID, span ID, trace state, and attributes. The view can resolve each destination in the configured trace source and show its span name, service, duration, and time when that span is available. An unresolved destination remains an ID-based link so the engineer can still open its trace.
The detail view can also show incoming links from spans whose link data points to the current span. These linked spans provide the source-side context for asynchronous work and let the engineer open the source span in its trace. This two-way view helps connect producer and consumer work when parent-child nesting does not describe the full request.
The link lists discard malformed identifiers and avoid duplicate span pairs. They also limit the amount of linked data shown at once, so a large link set does not overwhelm the detail view.
References: packages/…/SpanLinksSubpanel.tsx• L18-41 packages/…/SpanLinksSubpanel.tsx• L43-109 packages/…/SpanLinksSubpanel.tsx• L114-196 packages/…/SpanLinkedFromSubpanel.tsx• L17-59 packages/…/SpanLinkedFromSubpanel.tsx• L63-127 packages/…/linkedSpans.tsx• L31-69 packages/…/linkedSpans.tsx• L113-227 packages/…/linkedSpans.tsx• L286-387 packages/…/DBRowSidePanel.tsx• L614-645 packages/…/DBRowOverviewPanel.tsx• L328-343
Service and session context
The side panel can expose a service map when the selected record has both trace context and a trace source. The map gives a topology view for the same investigation. When a trace is also tied to a session source, the panel can open session replay without losing the trace record and its time context.
These views answer different questions. The waterfall explains the timing and order of work in one trace. The service map explains relationships between services. Session replay explains the user activity around the request. The links between them let an engineer use the right view without restarting the search.
References: packages/…/DBRowSidePanel.tsx• L532-662 packages/…/DBRowSidePanel.tsx• L762-778 packages/…/DBRowSidePanel.tsx• L1001-1095 packages/…/TraceTableModelForm.tsx• L225-243
Query capabilities
Trace investigation supports both focused record search and trace-shaped queries. The web waterfall uses the source's configured expressions and time range. The query tools provide the same investigation model for automated or scripted use.
Waterfall filters
The waterfall supports Lucene and SQL filters for spans and for correlated logs. The span filter can hide matching or non-matching rows in the tree. The log filter applies only to the correlated log source. Field suggestions use each source's schema, so a field name valid for spans is not assumed to be valid for logs.
The filters are stored with the trace view state. A shared link or reload can therefore restore the filter text and its query language instead of changing the meaning of the investigation. If a filter is invalid, the view keeps the unfiltered data and shows the filter error beside the affected input.
References: packages/…/DBTraceWaterfallChart.tsx• L700-763 packages/…/DBTraceWaterfallChart.tsx• L793-823 packages/…/DBTraceWaterfallChart.tsx• L1406-1483
Single-trace queries
The clickstack_trace_waterfall query capability returns one trace as a pre-ordered parent-child tree. An engineer can provide a trace ID or ask the tool to choose one matching trace by slowest span, first error, or most recent match. The result includes span timing, service and operation names, status, attributes, and optional correlated logs.
When the tool must locate a trace, the selection window is separate from the fetch window. The tool probes the selected trace's time extent so that a root or tail outside the search window can still appear. It bounds that fetch to protect query cost, and it reports when the probe fails, the fetch window is capped, or the result exceeds the span or log limit.
This capability is for understanding one concrete request. It is not the right choice for finding a population-wide latency cause. The trace source must be valid, and a result can be capped when a trace has more spans or logs than the requested limit.
References: packages/…/waterfall.ts• L34-122 packages/…/waterfall.ts• L224-300 packages/…/waterfall.ts• L310-336 packages/…/waterfall.ts• L389-549 packages/…/waterfall.ts• L551-655 packages/…/waterfall.ts• L658-785
Aggregate latency queries
The clickstack_trace_top_time_consuming_operations capability answers a broader question: which child operations consume the most total time across traces that match a parent operation. It first identifies matching parent traces, then ranks downstream work by cumulative time, call count, and latency measures.
The query uses a parent filter, time range, optional minimum parent duration, and limits for matching traces and returned operations. It widens the child time window slightly to catch work near the parent boundary. Results include each operation's share of total child time, which helps compare likely contributors across the selected traces.
This aggregate view is a useful step before opening a concrete waterfall. It separates “where does time go across many slow requests?” from “what happened in this one request?”. A focused parent condition that includes a service and operation produces a more useful result than a service-only condition.
References: packages/…/breakdown.ts• L44-56 packages/…/breakdown.ts• L64-100 packages/…/breakdown.ts• L103-188 packages/…/breakdown.ts• L200-257
Source-mapped frames
Exception details help an engineer connect a failed span or log to application code. The view presents exception type, message, handling state, stack frames, line context, and breadcrumbs when those values exist. JavaScript source maps can turn minified browser locations into source locations that are easier to act on.
Exception detail
The exception section appears in a row overview when exception event data is present. It shows the most useful frame first, keeps more frames behind an expand control, and presents breadcrumbs in time order. A frame can show its file, function, line, and column. When context is available, the frame can expand to show nearby source lines.
References: packages/…/DBRowOverviewPanel.tsx• L154-185 packages/…/ExceptionSubpanel.tsx• L44-54 packages/…/ExceptionSubpanel.tsx• L197-260 packages/…/ExceptionSubpanel.tsx• L472-534 packages/…/types.ts• L29-57
Source map workflow
The source map workflow starts when a build produces JavaScript map files. The CLI command upload-sourcemaps authenticates with a service key, finds the build files, and uploads them with an optional release ID and base path. The purpose is to make browser stack frames readable during exception investigation rather than to change the captured event.
The exception view can still show the original frame when no mapped result is available. An engineer should treat an unmapped file or line as a signal to check the build's map files, upload path, release association, and service-key result before assuming that the exception data is incomplete.
References: packages/…/cli.tsx• L1719-1754 packages/…/sourcemaps.ts• L38-167 packages/…/sourcemaps.ts• L171-224 packages/…/useSourceMappedFrame.tsx• L1-7 packages/…/ExceptionSubpanel.tsx• L218-251
Change checklist
When these files or sections are changed, remember to consider these:
- Keep trace, span, and parent-span source expressions aligned with the waterfall tree, direct trace lookup, row detail lookup, and automated waterfall queries.
- Keep trace-to-log correlation fields and source links aligned in both directions. A source selector can still render while related rows or linked traces silently disappear.
- Preserve the trace ID on selected-span URL state. Reusing a span selection across traces can show valid data in the wrong investigation.
- Keep the two waterfall filter states separate. A span filter must not change the source, language, or time range used by the correlated log filter.
- Keep duration precision consistent between source configuration, waterfall display, and aggregate time rankings. A unit mismatch changes the apparent cause of latency.
- Keep source map release and base-path naming aligned with the names in emitted browser frames. An upload can succeed while mapping still fails when those names do not match.
- Keep forward and reverse span-link lookups aligned with the same trace and span identity pair. Their time windows and result limits must still cover the expected producer and consumer delay.
- Preserve the shared linked-span key when changing link resolution or display. The resolved metadata map and both link lists depend on the same trace/span pair.
- Keep direct trace source resolution separate from default source selection. A missing source in a shared link must not silently change the requested investigation.
- Keep trace-query selection windows, fetch windows, and truncation notes aligned. A probe or cap can produce a partial tree even when the requested trace ID is valid.
- Keep aggregate child duration units aligned with the source precision and the reported millisecond fields. The ranking and share values depend on the same divisor.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Trace source is missing, invalid, or not a trace source | Direct trace navigation cannot render the waterfall | Select a valid trace source and verify its source configuration |
| Trace or log source lacks the configured correlation ID expression | Related logs do not appear, or a direct log-to-trace action cannot resolve | Configure matching trace ID and span ID expressions on the linked sources |
| Trace contains more spans or logs than the query limit | The tree or its context is incomplete | Narrow the time range or increase the span/log limit within the supported cap |
| Span parent records are absent from the result | The waterfall shows multiple roots or a less complete request path | Widen the time range and check ingestion completeness before reading tree depth as causality |
| A waterfall filter is invalid | Matching rows fall back to unfiltered data and the filter error is shown | Correct the filter in its own span or log query language |
| A direct link carries a source name that no longer resolves | The link keeps its requested source instead of selecting an unrelated default | Restore the source or choose one explicitly before applying the trace filter |
| The trace extent probe fails or its fetch window is capped | The automated waterfall may show a partial tree and reports a warning | Retry with an explicit time range around the trace or use a shorter trace window |
| A breakdown parent filter is invalid or scans too wide a time range | The aggregate query fails or times out before ranking child operations | Use valid ClickHouse SQL, narrow the window, scope the parent filter, or lower the parent-trace limit |
| A span link has no usable trace ID, span ID, or destination source | The link cannot open a destination trace | Keep link fields valid and configure the destination trace source |
| A linked span is outside the lookup window or has expired from storage | The detail view shows no resolved span metadata, or an incoming link is absent | Check the anchor time and retention window before treating the link as invalid |
| Browser source maps are missing or do not match uploaded names | Exception frames remain minified or show the wrong source location | Generate maps for the deployed build and upload them with the matching release and base path |
Key files
| File | Why to read it |
|---|---|
| packages/…/DBTracePanel.tsx | Defines the trace detail layout, source selection, span selection, and span detail tabs. |
| packages/…/DBTraceWaterfallChart.tsx | Defines the waterfall's tree, timeline, correlated rows, filters, display controls, service coloring, and truncation state. |
| packages/…/DirectTraceSidePanel.tsx | Shows how a trace ID enters the search-side-panel experience. |
| packages/…/DBRowSidePanel.tsx | Connects row details to trace, service map, session replay, breadcrumbs, and linked traces. |
| packages/…/DBRowOverviewPanel.tsx | Defines the span and log overview sections, including exceptions, events, attributes, and links. |
| packages/…/SpanLinksSubpanel.tsx | Defines outgoing span-link validation, metadata, attributes, and destination-trace actions. |
| packages/…/SpanLinkedFromSubpanel.tsx | Defines the incoming linked-span view and source-span navigation. |
| packages/…/linkedSpans.tsx | Defines the shared lookup model for forward and reverse linked spans and their display metadata. |
| packages/…/ExceptionSubpanel.tsx | Defines exception frames, line context, and breadcrumb presentation. |
| packages/…/TraceTableModelForm.tsx | Shows the trace source relationships and fields that make cross-signal investigation possible. |
| packages/…/DBSearchPage.directTrace.test.tsx | Shows the direct trace link, source resolution, query-state preservation, and close behavior that the search flow guarantees. |
| packages/…/waterfall.ts | Defines the single-trace query used to select, bound, and return a span tree with optional correlated logs. |
| packages/…/breakdown.ts | Defines the aggregate query used to rank time-consuming child operations across traces. |
| packages/…/sourcemaps.ts | Defines the source map upload workflow used to improve browser exception frames. |