Skip to content

feat(core): Pass normalizedRequest to the sampling context for root spans#21833

Merged
andreiborza merged 1 commit into
developfrom
ab/twp-standalone
Jun 29, 2026
Merged

feat(core): Pass normalizedRequest to the sampling context for root spans#21833
andreiborza merged 1 commit into
developfrom
ab/twp-standalone

Conversation

@andreiborza

@andreiborza andreiborza commented Jun 29, 2026

Copy link
Copy Markdown
Member

What

Forward the isolation scope's normalizedRequest into the tracesSampler sampling context for root spans. _startRootSpan now includes it in the object passed to the sampler.

Why

SamplingContext already advertises a normalizedRequest field, and server SDKs already record the incoming request on the isolation scope, but core never wired the two together for root spans, so tracesSampler always received normalizedRequest: undefined on the standard root-span path. This closes that gap so custom samplers can decide based on the incoming request (drop health-check routes, raise the rate for /api/*, key off the HTTP method) instead of reverse-engineering it from the span name or attributes, which for an incoming HTTP root span may not yet carry the route at sampling time.

Extracted standalone from #21666 (the SentryTracerProvider stack): it has no dependency on that work, ships on its own merits, and shrinks #21666's review surface.

…pans

Forward the isolation scope's normalizedRequest into the tracesSampler
sampling context for root spans, so sampling functions can decide based on
the incoming request (url, method, query string).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.48 kB - -
@sentry/browser - with treeshaking flags 25.91 kB - -
@sentry/browser (incl. Tracing) 45.98 kB +0.03% +10 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 47.73 kB +0.03% +11 B 🔺
@sentry/browser (incl. Tracing, Profiling) 50.77 kB +0.02% +10 B 🔺
@sentry/browser (incl. Tracing, Replay) 85.23 kB +0.02% +12 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.82 kB +0.02% +11 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 89.92 kB +0.02% +12 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 102.58 kB +0.02% +14 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.29 kB +0.02% +9 B 🔺
@sentry/vue 32.63 kB +0.04% +10 B 🔺
@sentry/vue (incl. Tracing) 47.84 kB +0.02% +9 B 🔺
@sentry/svelte 27.5 kB - -
CDN Bundle 29.89 kB - -
CDN Bundle (incl. Tracing) 47.9 kB +0.03% +12 B 🔺
CDN Bundle (incl. Logs, Metrics) 31.44 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.25 kB +0.03% +11 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 70.78 kB - -
CDN Bundle (incl. Tracing, Replay) 85.41 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.69 kB +0.02% +16 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 91.2 kB +0.02% +15 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.46 kB +0.02% +14 B 🔺
CDN Bundle - uncompressed 88.94 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.1 kB +0.06% +75 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.65 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.07 kB +0.06% +75 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.62 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.12 kB +0.03% +75 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.08 kB +0.03% +75 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.82 kB +0.03% +75 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.77 kB +0.03% +75 B 🔺
@sentry/nextjs (client) 50.68 kB +0.02% +9 B 🔺
@sentry/sveltekit (client) 46.38 kB +0.03% +11 B 🔺
@sentry/core/server 77.55 kB +0.02% +10 B 🔺
@sentry/core/browser 63.89 kB +0.03% +14 B 🔺
@sentry/node-core 61.52 kB +0.02% +11 B 🔺
@sentry/node 123.5 kB +0.01% +8 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.42 kB +0.05% +21 B 🔺
@sentry/node - without tracing 73.62 kB +0.02% +8 B 🔺
@sentry/aws-serverless 84.41 kB +0.01% +8 B 🔺
@sentry/cloudflare (withSentry) - minified 180.38 kB +0.05% +75 B 🔺
@sentry/cloudflare (withSentry) 446.33 kB +0.03% +96 B 🔺

View base workflow run

@andreiborza andreiborza merged commit 128dacb into develop Jun 29, 2026
559 of 561 checks passed
@andreiborza andreiborza deleted the ab/twp-standalone branch June 29, 2026 09:41
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.

3 participants