Skip to content

fix(opentelemetry): Ensure withScope keeps span active & _getTraceInfoFromScope works #16385

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

Merged
merged 1 commit into from
May 26, 2025

Conversation

mydea
Copy link
Member

@mydea mydea commented May 26, 2025

Also ensure that withScope(scope, callback) maintains the active span from the passed in scope.

Fixes #16361

The problem here was that we used the _getSpanForScope method in core for this, but this only actually works for the core implementation, not the node one 😬 So I rewrote this to use more general utilities, which should work isomorphically. While doing this, I noticed an actual bug in the withScope implementation in otel, where we did not actually keep the active span correctly.

@mydea mydea requested a review from AbhiPrasad May 26, 2025 08:28
@mydea mydea self-assigned this May 26, 2025
Also ensure that `withScope(scope, callback)` maintains the active span from the passed in scope.
@mydea mydea force-pushed the fn/fix-node-get-trace-info-from-scope branch from 4863dec to 4f36293 Compare May 26, 2025 10:33
Copy link
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.95 kB - -
@sentry/browser - with treeshaking flags 23.72 kB - -
@sentry/browser (incl. Tracing) 38.27 kB - -
@sentry/browser (incl. Tracing, Replay) 76.39 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.5 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 81.17 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 93.26 kB - -
@sentry/browser (incl. Feedback) 40.72 kB - -
@sentry/browser (incl. sendFeedback) 28.68 kB - -
@sentry/browser (incl. FeedbackAsync) 33.57 kB - -
@sentry/react 25.73 kB - -
@sentry/react (incl. Tracing) 40.25 kB - -
@sentry/vue 28.35 kB - -
@sentry/vue (incl. Tracing) 40.1 kB - -
@sentry/svelte 23.98 kB - -
CDN Bundle 25.25 kB - -
CDN Bundle (incl. Tracing) 38.39 kB - -
CDN Bundle (incl. Tracing, Replay) 74.25 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 79.67 kB - -
CDN Bundle - uncompressed 73.67 kB - -
CDN Bundle (incl. Tracing) - uncompressed 113.69 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 227.66 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 240.49 kB - -
@sentry/nextjs (client) 41.91 kB - -
@sentry/sveltekit (client) 38.75 kB - -
@sentry/node 149.46 kB +0.03% +41 B 🔺
@sentry/node - without tracing 98.13 kB +0.04% +36 B 🔺
@sentry/aws-serverless 123.48 kB +0.05% +50 B 🔺

View base workflow run

@AbhiPrasad
Copy link
Member

Going to merge this in so that I can open a PR to add more tests for this!

@AbhiPrasad AbhiPrasad merged commit e46c619 into develop May 26, 2025
160 checks passed
@AbhiPrasad AbhiPrasad deleted the fn/fix-node-get-trace-info-from-scope branch May 26, 2025 17:10
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.

Structured log traces do not correlate with any traces collected
2 participants