Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

Enable new trace details page (#11296)

Aditya Singh3bea4484f976
diff --git a/frontend/src/AppRoutes/routes.ts b/frontend/src/AppRoutes/routes.ts
index 155adf29dd..563147222a 100644
--- a/frontend/src/AppRoutes/routes.ts
+++ b/frontend/src/AppRoutes/routes.ts
@@ -144,18 +144,18 @@ const routes: AppRoutes[] = [
// /trace-old serves V3 (URL-only access). Flip the two `component`
// values back to release V3.
{
- path: ROUTES.TRACE_DETAIL,
+ path: ROUTES.TRACE_DETAIL_OLD,
exact: true,
component: TraceDetail,
isPrivate: true,
- key: 'TRACE_DETAIL',
+ key: 'TRACE_DETAIL_OLD',
},
{
- path: ROUTES.TRACE_DETAIL_OLD,
+ path: ROUTES.TRACE_DETAIL,
exact: true,
component: TraceDetailV3,
isPrivate: true,
- key: 'TRACE_DETAIL_OLD',
+ key: 'TRACE_DETAIL',
},
{
path: ROUTES.SETTINGS,
diff --git a/frontend/src/pages/TraceDetailsV3/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx b/frontend/src/pages/TraceDetailsV3/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx
index 50b8ab57d2..5085be5d17 100644
--- a/frontend/src/pages/TraceDetailsV3/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx
+++ b/frontend/src/pages/TraceDetailsV3/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx
@@ -473,6 +473,7 @@ export const SpanDuration = memo(function SpanDuration({
const columnDefHelper = createColumnHelper<SpanV3>();
const ROW_HEIGHT = 28;
+const WATERFALL_BOTTOM_PADDING = 24;
const DEFAULT_SIDEBAR_WIDTH = 450;
const MIN_SIDEBAR_WIDTH = 240;
const MAX_SIDEBAR_WIDTH = 900;
@@ -740,53 +741,69 @@ function Success(props: ISuccessProps): JSX.Element {
);
}, [spans, sidebarWidth]);
- // Scroll to the interested span only when it isn't already on screen.
- // Covers every entry point uniformly: deep-link, flamegraph click,
- // filter prev/next, browser back/forward all scroll only if needed;
- // waterfall row clicks and chevron expand/collapse don't yank the viewport
- // because the affected row is by definition already visible.
+ // Scroll a span to viewport center if it isn't already visible. Shared by
+ // the two effects below — one keyed on interestedSpanId (chevron, boundary
+ // pagination, deep-link to unloaded), the other on selectedSpan (in-window
+ // URL navigation that doesn't mutate interestedSpanId).
+ const scrollSpanIntoView = useCallback(
+ (span: SpanV3, spansList: SpanV3[]): void => {
+ if (!virtualizerRef.current) {
+ return;
+ }
+ const idx = spansList.findIndex((s) => s.span_id === span.span_id);
+ if (idx === -1) {
+ return;
+ }
+ const scrollEl = scrollContainerRef.current;
+ const scrollTop = scrollEl?.scrollTop ?? 0;
+ const viewportHeight = scrollEl?.clientHeight ?? 0;
+ const viewportStartIdx = Math.floor(scrollTop / ROW_HEIGHT);
+ const viewportEndIdx =
+ Math.ceil((scrollTop + viewportHeight) / ROW_HEIGHT) - 1;
+ const isOnScreen =
+ viewportHeight > 0 && idx >= viewportStartIdx && idx <= viewportEndIdx;
+ if (isOnScreen) {
+ return;
+ }
+ setTimeout(() => {
+ virtualizerRef.current?.scrollToIndex(idx, {
+ align: 'center',
+ behavior: 'auto',
+ });
+ const sidebarScrollEl = scrollContainerRef.current?.querySelector(
+ '.resizable-box__content',
+ );
+ if (sidebarScrollEl) {
+ const targetScrollLeft = Math.max(0, span.level * CONNECTOR_WIDTH - 40);
+ (sidebarScrollEl as HTMLElement).scrollLeft = targetScrollLeft;
+ }
+ }, 100);
+ },
+ [],
+ );
+
useEffect(() => {
- if (interestedSpanId.spanId !== '' && virtualizerRef.current) {
+ if (interestedSpanId.spanId !== '') {
const idx = spans.findIndex(
(span) => span.span_id === interestedSpanId.spanId,
);
if (idx !== -1) {
- const visible = virtualizerRef.current.getVirtualItems();
- const isOnScreen =
- visible.length > 0 &&
- idx >= visible[0].index &&
- idx <= visible[visible.length - 1].index;
-
- if (!isOnScreen) {
- setTimeout(() => {
- virtualizerRef.current?.scrollToIndex(idx, {
- align: 'center',
- behavior: 'auto',
- });
-
- // Auto-scroll sidebar horizontally to show the span name
- const span = spans[idx];
- const sidebarScrollEl = scrollContainerRef.current?.querySelector(
- '.resizable-box__content',
- );
- if (sidebarScrollEl) {
- const targetScrollLeft = Math.max(0, span.level * CONNECTOR_WIDTH - 40);
- sidebarScrollEl.scrollLeft = targetScrollLeft;
- }
- }, 400);
- }
-
+ scrollSpanIntoView(spans[idx], spans);
setSelectedSpan(spans[idx]);
}
} else {
- setSelectedSpan((prev) => {
- if (!prev) {
- return spans[0];
- }
- return prev;
- });
+ setSelectedSpan((prev) => prev ?? spans[0]);
+ }
+ }, [interestedSpanId, setSelectedSpan, spans, scrollSpanIntoView]);
+
+ // Covers URL-driven navigation to an already-loaded span (flamegraph /
+ // filter / browser back) that the interestedSpanId-keyed effect doesn't see.
+ useEffect(() => {
+ if (selectedSpan) {
+ scrollSpanIntoView(selectedSpan, spans);
}
- }, [interestedSpanId, setSelectedSpan, spans]);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [selectedSpan, scrollSpanIntoView]);
const virtualItems = virtualizer.getVirtualItems();
const leftRows = leftTable.getRowModel().rows;
@@ -846,7 +863,7 @@ function Success(props: ISuccessProps): JSX.Element {
<div
className={styles.splitBody}
style={{
- minHeight: virtualizer.getTotalSize(),
+ minHeight: virtualizer.getTotalSize() + WATERFALL_BOTTOM_PADDING,
height: '100%',
}}
>
diff --git a/frontend/src/pages/TraceDetailsV3/index.tsx b/frontend/src/pages/TraceDetailsV3/index.tsx
index 5ad66efa2b..4fb08a1a47 100644
--- a/frontend/src/pages/TraceDetailsV3/index.tsx
+++ b/frontend/src/pages/TraceDetailsV3/index.tsx
@@ -74,17 +74,21 @@ function TraceDetailsV3(): JSX.Element {
onClose: handleSpanDetailsClose,
});
+ const allSpansRef = useRef<SpanV3[]>([]);
+
+ // Refetch only when the URL target isn't already loaded. Keeps row clicks
+ // and other in-window URL navigation from triggering a backend window slide.
useEffect(() => {
const spanId = urlQuery.get('spanId') || '';
- // Only update interestedSpanId when a new span is selected,
- // not when it's cleared (panel close) — avoids unnecessary API refetch
if (!spanId) {
return;
}
- setInterestedSpanId({
- spanId,
- isUncollapsed: true,
- });
+ const idx = allSpansRef.current.findIndex((s) => s.span_id === spanId);
+ if (idx !== -1) {
+ setSelectedSpan(allSpansRef.current[idx]);
+ return;
+ }
+ setInterestedSpanId({ spanId, isUncollapsed: true });
}, [urlQuery]);
// Hardcoded for now — fetch aggregations for all 3 candidate color-by fields
@@ -145,6 +149,10 @@ function TraceDetailsV3(): JSX.Element {
};
}
+ useEffect(() => {
+ allSpansRef.current = allSpans;
+ }, [allSpans]);
+
// Frontend mode: expand all parents by default when full data arrives
useEffect(() => {
if (isFullDataLoaded && allSpans.length > 0) {