Skip to content
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

SentryScope.Transaction should always be AsyncLocal #3590

Closed
jamescrosswell opened this issue Sep 2, 2024 · 1 comment · Fixed by #3596
Closed

SentryScope.Transaction should always be AsyncLocal #3590

jamescrosswell opened this issue Sep 2, 2024 · 1 comment · Fixed by #3596
Milestone

Comments

@jamescrosswell
Copy link
Collaborator

jamescrosswell commented Sep 2, 2024

Originally posted by @jamescrosswell in #3546

Problem

When IsGlobalModeEnabled == true, spans from the UI can get mixed up with transactions in background services, and vice versa.

Originally Global Mode was added so that tags and context that get set in the UI also get applied to exceptions that get thrown in background threads. This makes sense for Events/Exceptions. However, unless they share an AsyncLocal context, it doesn't make sense for spans from one thread to end up under transactions that were created in another thread.

Solution

The "Current" transaction should always be stored as an AsyncLocal, regardless of what kind of scope stack manager is configured for the application more generally.

Compatibility with OpenTelemetry

This would be the same as the behaviour for OpenTelemetry traces, since Activity.Current is declared as static AsyncLocal<Activity>.

@jamescrosswell jamescrosswell added this to the 5.0.0 milestone Sep 2, 2024
@jamescrosswell jamescrosswell changed the title Remove SentryScope.Transaction SentryScope.Transaction should always be AsyncLocal Sep 5, 2024
@jamescrosswell jamescrosswell linked a pull request Sep 5, 2024 that will close this issue
@bruno-garcia
Copy link
Member

Compatibility with OpenTelemetry

GlobalMode is used on mobile and desktop and I'm not sure how popular, or even if it's compatible, with OTel. I mean I'm sure desktop is, but Mobile I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants