Skip to content

fix(replays): Record replay trace_ids with span streaming#21714

Merged
mjq merged 2 commits into
developfrom
mjq/span-streaming-replay-traceids
Jun 23, 2026
Merged

fix(replays): Record replay trace_ids with span streaming#21714
mjq merged 2 commits into
developfrom
mjq/span-streaming-replay-traceids

Conversation

@mjq

@mjq mjq commented Jun 23, 2026

Copy link
Copy Markdown
Member

Replay events' trace_ids property is currently only set in handleTransactionEvent:

function handleTransactionEvent(replay: ReplayContainer, event: TransactionEvent): void {
const replayContext = replay.getContext();
// Collect traceIds in _context regardless of `recordingMode`
// In error mode, _context gets cleared on every checkout
// We limit to max. 100 transactions linked
if (event.contexts?.trace?.trace_id && replayContext.traceIds.size < 100) {
replayContext.traceIds.add(event.contexts.trace.trace_id);
}
}

This never fires when span streaming is enabled, as we no longer emit transaction events. As a consequence, replays' trace_ids list is always empty under span streaming.

Add another equivalent hook on afterSegmentSpanEnd to record trace_ids when span streaming is enabled.

Only sampled spans are considered, which matches the previous behaviour for transactions.


🤖: Claude/Opus 4.6 did a first pass and then I refactored it into shape. Claude wrote the tests though (looked fine to me).

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.47 kB - -
@sentry/browser - with treeshaking flags 25.91 kB - -
@sentry/browser (incl. Tracing) 45.96 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 47.72 kB - -
@sentry/browser (incl. Tracing, Profiling) 50.75 kB - -
@sentry/browser (incl. Tracing, Replay) 85.21 kB +0.05% +39 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.81 kB +0.06% +39 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 89.91 kB +0.05% +43 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 102.57 kB +0.05% +42 B 🔺
@sentry/browser (incl. Feedback) 44.66 kB - -
@sentry/browser (incl. sendFeedback) 32.26 kB - -
@sentry/browser (incl. FeedbackAsync) 37.4 kB - -
@sentry/browser (incl. Metrics) 28.54 kB - -
@sentry/browser (incl. Logs) 28.78 kB - -
@sentry/browser (incl. Metrics & Logs) 29.47 kB - -
@sentry/react 29.27 kB - -
@sentry/react (incl. Tracing) 48.28 kB - -
@sentry/vue 32.62 kB - -
@sentry/vue (incl. Tracing) 47.83 kB - -
@sentry/svelte 27.5 kB - -
CDN Bundle 29.88 kB - -
CDN Bundle (incl. Tracing) 47.9 kB - -
CDN Bundle (incl. Logs, Metrics) 31.44 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.24 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.77 kB +0.05% +32 B 🔺
CDN Bundle (incl. Tracing, Replay) 85.41 kB +0.19% +158 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.69 kB +0.19% +159 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.2 kB +0.12% +106 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.45 kB +0.11% +101 B 🔺
CDN Bundle - uncompressed 88.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.02 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.65 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 148.99 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.62 kB +0.07% +148 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.03 kB +0.06% +148 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 267.99 kB +0.06% +148 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.73 kB +0.06% +148 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.68 kB +0.06% +148 B 🔺
@sentry/nextjs (client) 50.67 kB - -
@sentry/sveltekit (client) 46.37 kB - -
@sentry/core/server 76.32 kB - -
@sentry/core/browser 63.48 kB - -
@sentry/node-core 61.63 kB +0.01% +1 B 🔺
@sentry/node 123.61 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.55 kB - -
@sentry/node - without tracing 73.69 kB - -
@sentry/aws-serverless 84.89 kB - -
@sentry/cloudflare (withSentry) - minified 175.71 kB - -
@sentry/cloudflare (withSentry) 437.11 kB - -

View base workflow run

@mjq mjq force-pushed the mjq/span-streaming-replay-traceids branch from 614abab to f20f909 Compare June 23, 2026 19:37
cursor[bot]

This comment was marked as resolved.

@mjq mjq marked this pull request as ready for review June 23, 2026 19:53
@mjq mjq requested a review from a team as a code owner June 23, 2026 19:53
@mjq mjq requested review from Lms24, logaretm and mydea and removed request for a team June 23, 2026 19:53
@mjq mjq enabled auto-merge (squash) June 23, 2026 20:20
@mjq mjq merged commit 2bad655 into develop Jun 23, 2026
403 of 405 checks passed
@mjq mjq deleted the mjq/span-streaming-replay-traceids branch June 23, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants