diff --git a/static/app/views/performance/newTraceDetails/traceLinksNavigation/useFindLinkedTraces.ts b/static/app/views/performance/newTraceDetails/traceLinksNavigation/useFindLinkedTraces.ts index b92342b6c53ac1..d4e995f1b230f5 100644 --- a/static/app/views/performance/newTraceDetails/traceLinksNavigation/useFindLinkedTraces.ts +++ b/static/app/views/performance/newTraceDetails/traceLinksNavigation/useFindLinkedTraces.ts @@ -30,7 +30,6 @@ export function useFindAdjacentTrace({ projectId, environment, currentTraceId, - currentSpanId, adjacentTraceId, adjacentTraceSpanId, hasAdjacentTraceLink, @@ -39,7 +38,6 @@ export function useFindAdjacentTrace({ let _projectId: number | undefined = undefined; let _environment: string | undefined = undefined; let _currentTraceId: string | undefined; - let _currentSpanId: string | undefined; let _adjacentTraceAttribute: TraceItemResponseAttribute | undefined = undefined; for (const a of attributes ?? []) { @@ -49,8 +47,6 @@ export function useFindAdjacentTrace({ _environment = a.value; } else if (a.name === 'trace' && a.type === 'str') { _currentTraceId = a.value; - } else if (a.name === 'transaction.span_id' && a.type === 'str') { - _currentSpanId = a.value; } else if (a.name === 'previous_trace' && a.type === 'str') { _adjacentTraceAttribute = a; } @@ -74,7 +70,6 @@ export function useFindAdjacentTrace({ projectId: _projectId, environment: _environment, currentTraceId: _currentTraceId, - currentSpanId: _currentSpanId, hasAdjacentTraceLink: _hasAdjacentTraceLink, adjacentTraceSampled: _adjacentTraceSampledFlag === '1', adjacentTraceId: _adjacentTraceId, @@ -84,7 +79,12 @@ export function useFindAdjacentTrace({ const searchQuery = direction === 'next' - ? `sentry.previous_trace:${currentTraceId}-${currentSpanId}-1` + ? // relaxed the next trace lookup to match spans containing only the + // traceId and not the spanId of the current trace root. We can't + // always be sure that the current trace root is indeed the span the + // next span would link towards, because sometimes the root might be a web + // vital span instead of the actual intial span from the SDK's perspective. + `sentry.previous_trace:${currentTraceId}-*-1` : `id:${adjacentTraceSpanId} trace:${adjacentTraceId}`; const enabled =