Skip to content

fix(browser): Propagate trace data from active span if http.client span is non-recording#22246

Merged
Lms24 merged 3 commits into
lms/fix-node-ative-span-http-client-non-recordingfrom
lms/fix-browser-active-span-http-client-non-recording
Jul 16, 2026
Merged

fix(browser): Propagate trace data from active span if http.client span is non-recording#22246
Lms24 merged 3 commits into
lms/fix-node-ative-span-http-client-non-recordingfrom
lms/fix-browser-active-span-http-client-non-recording

Conversation

@Lms24

@Lms24 Lms24 commented Jul 14, 2026

Copy link
Copy Markdown
Member

This PR fixes an inconsistency with trace propagation via browser http.client spans: If an http.client span was started as a NonRecordingSpan we'd still take it as the span we generate our tracing headers from (via getTraceData). What we should do instead is to propagate the currently active span, so that span trees from a downstream service don't become orphaned.

This PR also adds integration tests for 3 scenarios with ignoreSpans:

  • ignoring a segment span should force a negative sampling decision on propagation, even if the incoming trace is sampled positively
  • ignoring a child span should continue the segment span's sampling decision on propagation
  • akin: ignoring an http.client span should still continue the positive sampling decision on propagation

ref: #22262

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.72 kB +0.18% +49 B 🔺
@sentry/browser - with treeshaking flags 26.17 kB +0.19% +48 B 🔺
@sentry/browser (incl. Tracing) 46.55 kB +0.23% +103 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.33 kB +0.2% +96 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.32 kB +0.19% +97 B 🔺
@sentry/browser (incl. Tracing, Replay) 85.78 kB +0.11% +88 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.42 kB +0.12% +89 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 90.5 kB +0.1% +90 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 103.15 kB +0.09% +85 B 🔺
@sentry/browser (incl. Feedback) 44.9 kB +0.11% +46 B 🔺
@sentry/browser (incl. sendFeedback) 32.52 kB +0.15% +46 B 🔺
@sentry/browser (incl. FeedbackAsync) 37.65 kB +0.13% +47 B 🔺
@sentry/browser (incl. Metrics) 28.81 kB +0.16% +46 B 🔺
@sentry/browser (incl. Logs) 29.05 kB +0.17% +47 B 🔺
@sentry/browser (incl. Metrics & Logs) 29.73 kB +0.17% +49 B 🔺
@sentry/react 29.53 kB +0.17% +49 B 🔺
@sentry/react (incl. Tracing) 48.79 kB +0.19% +92 B 🔺
@sentry/vue 33.15 kB +0.15% +47 B 🔺
@sentry/vue (incl. Tracing) 48.52 kB +0.21% +98 B 🔺
@sentry/svelte 27.75 kB +0.19% +50 B 🔺
CDN Bundle 30.12 kB +0.16% +46 B 🔺
CDN Bundle (incl. Tracing) 48.51 kB +0.17% +81 B 🔺
CDN Bundle (incl. Logs, Metrics) 31.7 kB +0.17% +51 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 49.81 kB +0.16% +78 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 70.94 kB +0.08% +50 B 🔺
CDN Bundle (incl. Tracing, Replay) 86 kB +0.09% +76 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.31 kB +0.09% +78 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.8 kB +0.1% +85 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 93.06 kB +0.09% +76 B 🔺
CDN Bundle - uncompressed 89.78 kB +0.09% +80 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 146.59 kB +0.1% +143 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.48 kB +0.09% +80 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.56 kB +0.1% +143 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.21 kB +0.04% +80 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.79 kB +0.06% +143 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.75 kB +0.06% +143 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.49 kB +0.06% +143 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.44 kB +0.06% +143 B 🔺
@sentry/nextjs (client) 51.35 kB +0.2% +102 B 🔺
@sentry/sveltekit (client) 46.97 kB +0.19% +88 B 🔺
@sentry/core/server 78.6 kB +0.08% +56 B 🔺
@sentry/core/browser 64.95 kB +0.09% +57 B 🔺
@sentry/node-core 63.17 kB -0.29% -179 B 🔽
@sentry/node 125.41 kB +0.06% +65 B 🔺
@sentry/node (incl. diagnostics channel injection) 140.45 kB +0.05% +58 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB - -
@sentry/node/light 51.3 kB +0.09% +42 B 🔺
@sentry/node - without tracing 74.67 kB +0.05% +30 B 🔺
@sentry/aws-serverless 83.9 kB +0.04% +26 B 🔺
@sentry/cloudflare (withSentry) - minified 182.02 kB +0.07% +115 B 🔺
@sentry/cloudflare (withSentry) 450.69 kB +0.1% +436 B 🔺

View base workflow run

@Lms24
Lms24 marked this pull request as ready for review July 14, 2026 13:11
@Lms24
Lms24 requested a review from a team as a code owner July 14, 2026 13:11
@Lms24
Lms24 requested review from logaretm, msonnb and mydea and removed request for a team July 14, 2026 13:11
@Lms24 Lms24 changed the title fix(browser): Propagate trace data from active span if http.client span is not recording fix(browser): Propagate trace data from active span if http.client span is not recording Jul 14, 2026
@Lms24 Lms24 self-assigned this Jul 14, 2026
@Lms24 Lms24 changed the title fix(browser): Propagate trace data from active span if http.client span is not recording fix(browser): Propagate trace data from active span if http.client span is non-recording Jul 15, 2026
@Lms24
Lms24 force-pushed the lms/fix-browser-active-span-http-client-non-recording branch from f503cbe to ace6029 Compare July 15, 2026 11:29
@Lms24
Lms24 requested review from a team as code owners July 15, 2026 11:29
@Lms24
Lms24 requested review from JPeer264 and isaacs and removed request for a team July 15, 2026 11:29
@Lms24
Lms24 changed the base branch from develop to lms/fix-node-ative-span-http-client-non-recording July 15, 2026 11:29
@Lms24
Lms24 removed request for a team, JPeer264 and isaacs July 15, 2026 12:50
@Lms24
Lms24 force-pushed the lms/fix-node-ative-span-http-client-non-recording branch from 71c3abc to 2312ed3 Compare July 15, 2026 14:55
@Lms24
Lms24 force-pushed the lms/fix-browser-active-span-http-client-non-recording branch from ace6029 to 19e1891 Compare July 15, 2026 14:55
Lms24 and others added 3 commits July 15, 2026 18:35
Expect the incoming DSC fields to be preserved while the ignored segment
changes the propagated sampling decision to false.

Co-Authored-By: Cursor <cursoragent@cursor.com>
@Lms24
Lms24 force-pushed the lms/fix-browser-active-span-http-client-non-recording branch from 19e1891 to f3a2c1e Compare July 15, 2026 16:36
@Lms24
Lms24 force-pushed the lms/fix-node-ative-span-http-client-non-recording branch from fa4ba70 to c13f7d1 Compare July 15, 2026 16:36
@Lms24
Lms24 merged commit 667cb71 into develop Jul 16, 2026
616 of 649 checks passed
@Lms24
Lms24 deleted the lms/fix-browser-active-span-http-client-non-recording branch July 16, 2026 08:37
Lms24 added a commit that referenced this pull request Jul 16, 2026
This PR preserves trace propagation for ignored spans in span streaming
mode:
- When segment spans are ignored, incoming DSC (via baggage) is kept
as-is, but is mutated to carry a negative sampling decision, in line
with the `sentry-trace` header, which already emitted a negative
sampling decision
- ignored child and HTTP client spans propagate from the nearest emitted
parent across fetch, `node:http`
- For Orchestrion/tracing-channel-based instrumentation, we only set a
child span as the active span if it is not ignored. This was already
implemented in the OTel context manager previously but probably didn't
get ported correctly to the new approach.
 
Turns out, the DSC changes are also a requirement for #22246, so I threw
it on top of this PR.

ref #22262

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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