Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(browser): Add experimental parentlessRootSpans browserTracingIntegration option #17527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
Lms24 wants to merge 3 commits into develop
base: develop
Choose a base branch
Loading
from lms/feat-exp-parentlessBrowserSpans

Conversation

Copy link
Member

@Lms24 Lms24 commented Sep 4, 2025
edited
Loading

Experiment for now. TBD if we want to merge this.

This PR introduces a new idea how we continue SSR traces in the browser, based on <meta> tags. Previously, we'd simply continue the trace as if the SSR server-side span was the parent span of the pageload and all subsequent spans.

This has a couple of disadvantages, espsecially when subsequent browser-local root spans spans were started: All of them would count as child spans of the initial http.sever span. For some time, we had logic in the Sentry UI to artificially turn around the span relationships but this didn't work consistently within the trace view and even worse across multiple products. We'll fix this product-side by removing the reparenting logic and more clearly marking a trace as an SSR to explain why the trace looks like it does.

But what, if it doesn't have to be this way?

With this PR, we're experimenting with a different way to connect browser-local root spans with the http.server span:

  • We still continue the traceId as well as of course the sampling decision and any other trace data items.
  • With the important exception of the parentSpanId. Instead, we explicitly do not set a parent span id, making the browser-local root spans become actual root spans in the trace.
  • We attach a span link to the browser.request span that connects this span to the SSR http.server span. This should be enough information for the product, to eventually still show the connection in the trace view.
  • Importantly, this means that the product will show all browser spans as root spans now and, due to timing, the "trace root" will be the pageload span.
image image

Drawbacks:

  • The SSR http.server span is still not a child of the browser.request span. We can't solve this reliably on a technical level (requires major hacks, uncertainties and SDK changes across all our SDKs). The product can still artificially reparent these spans, though only this time, it knows exactly what to do and doesn't have to rely on heuristics.
  • We now always emit traces with multiple root spans in case of SSR.

seer-by-sentry[bot] reacted with hooray emoji
@Lms24 Lms24 marked this pull request as draft September 4, 2025 07:26
Copy link
Contributor

github-actions bot commented Sep 4, 2025
edited
Loading

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.16 kB - -
@sentry/browser - with treeshaking flags 22.73 kB - -
@sentry/browser (incl. Tracing) 39.96 kB +0.23% +89 B 🔺
@sentry/browser (incl. Tracing, Replay) 78.33 kB +0.12% +93 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.11 kB +0.13% +88 B 🔺
⛔️ @sentry/browser (incl. Tracing, Replay with Canvas) (max: 83 kB) 83.01 kB +0.12% +96 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 95.19 kB +0.1% +88 B 🔺
@sentry/browser (incl. Feedback) 40.89 kB - -
@sentry/browser (incl. sendFeedback) 28.81 kB - -
@sentry/browser (incl. FeedbackAsync) 33.75 kB - -
@sentry/react 25.88 kB - -
@sentry/react (incl. Tracing) 41.97 kB +0.19% +77 B 🔺
@sentry/vue 28.64 kB - -
@sentry/vue (incl. Tracing) 41.78 kB +0.21% +87 B 🔺
@sentry/svelte 24.18 kB - -
CDN Bundle 25.66 kB - -
CDN Bundle (incl. Tracing) 39.83 kB +0.21% +82 B 🔺
CDN Bundle (incl. Tracing, Replay) 76.11 kB +0.11% +82 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 81.59 kB +0.11% +82 B 🔺
CDN Bundle - uncompressed 74.96 kB - -
CDN Bundle (incl. Tracing) - uncompressed 117.85 kB +0.23% +261 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 232.95 kB +0.12% +261 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 245.71 kB +0.11% +261 B 🔺
@sentry/nextjs (client) 43.97 kB +0.19% +83 B 🔺
@sentry/sveltekit (client) 40.41 kB +0.2% +80 B 🔺
@sentry/node-core 49.61 kB +0.01% +1 B 🔺
@sentry/node 150.27 kB -0.01% -1 B 🔽
@sentry/node - without tracing 92.18 kB +0.01% +1 B 🔺
@sentry/aws-serverless 105.48 kB - -

View base workflow run

Copy link
Contributor

github-actions bot commented Sep 4, 2025
edited
Loading

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 8,877 - 8,687 +2%
GET With Sentry 1,269 14% 1,275 -0%
GET With Sentry (error only) 5,883 66% 5,998 -2%
POST Baseline 1,079 - 1,142 -6%
POST With Sentry 531 49% 496 +7%
POST With Sentry (error only) 1,053 98% 984 +7%
MYSQL Baseline 3,301 - 3,247 +2%
MYSQL With Sentry 411 12% 435 -6%
MYSQL With Sentry (error only) 2,673 81% 2,648 +1%

View base workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /