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

@mjqmjq commented Jun 23, 2026

Copy link
Copy Markdown
Member

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

functionhandleTransactionEvent(replay: ReplayContainer,event: TransactionEvent): void{
constreplayContext=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-actionsBot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.47 kB--
@sentry/browser - with treeshaking flags25.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 flags74.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/react29.27 kB--
@sentry/react (incl. Tracing)48.28 kB--
@sentry/vue32.62 kB--
@sentry/vue (incl. Tracing)47.83 kB--
@sentry/svelte27.5 kB--
CDN Bundle29.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 - uncompressed88.95 kB--
CDN Bundle (incl. Tracing) - uncompressed145.02 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed93.65 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed148.99 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.62 kB+0.07%+148 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed264.03 kB+0.06%+148 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed267.99 kB+0.06%+148 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed277.73 kB+0.06%+148 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed281.68 kB+0.06%+148 B 🔺
@sentry/nextjs (client)50.67 kB--
@sentry/sveltekit (client)46.37 kB--
@sentry/core/server76.32 kB--
@sentry/core/browser63.48 kB--
@sentry/node-core61.63 kB+0.01%+1 B 🔺
@sentry/node123.61 kB--
@sentry/node/import (ESM hook with diagnostics-channel injection)69.95 kB--
@sentry/node/light50.55 kB--
@sentry/node - without tracing73.69 kB--
@sentry/aws-serverless84.89 kB--
@sentry/cloudflare (withSentry) - minified175.71 kB--
@sentry/cloudflare (withSentry)437.11 kB--

View base workflow run

@mjq
mjqforce-pushed the mjq/span-streaming-replay-traceids branch from 614abab to f20f909CompareJune 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 ownerJune 23, 2026 19:53
@mjq
mjq requested review from Lms24, logaretm and mydea and removed request for a teamJune 23, 2026 19:53
@mjq
mjq enabled auto-merge (squash) June 23, 2026 20:20
@mjq
mjq merged commit 2bad655 into developJun 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 freeto 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

@mjq@logaretm