dotnet: clarify global mode transaction state#12919
Merged
Merged
Conversation
|
@mattico is attempting to deploy a commit to the Sentry Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
@jamescrosswell do you have any thought on this? |
Contributor
Author
|
Taking another crack at it: When Global Mode is **enabled**, a single scope stack is shared by the whole application. This is the recommended mode for UI applications.
When Global Mode is **disabled**, the scope data is tied to the currently executing context. This is the recommended mode for server applications.
Since version 5.0.0 the scope's `Transaction` is always tied to the currently executing context, regardless of the Global Mode configuration.
<Alert level="info">
What does it mean for data to be "tied to the currently executing context?" In general, each async `Task`, `Thread`, or web request
has its own ExecutionContext. Data which is written to this context is visible to child tasks or threads, but not to parent tasks
or threads.
For more information see [the .NET ExecutionContext documentation](https://learn.microsoft.com/en-us/dotnet/api/system.threading.executioncontext).
</Alert> |
jamescrosswell
approved these changes
Mar 27, 2025
jamescrosswell
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the PR @mattico! Much appreciated ❤️
I've suggested one small tweak to the wording on the last paragraph but otherwise all good!
Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
jamescrosswell
approved these changes
Mar 31, 2025
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
bitsandfoxes
approved these changes
Apr 4, 2025
Contributor
|
Thanks a lot! And thanks for your (collective) patience! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DESCRIBE YOUR PR
Tell us what you're changing and why. If your PR resolves an issue, please link it so it closes automatically.
Following getsentry/sentry-dotnet#3596, the scope Transaction is always stored in an AsyncLocal, regardless of the GlobalMode configuration. Updating the docs to state this will help others avoid needing to read the SDK source in order to figure out why their transactions become unset on the scope during task switches.
I'm not completely sure about the wording. The nice thing about ExecutionContext and the GlobalMode defaults is that in the vast majority of cases they work intuitively, and ExecutionContext is an implementation detail that users can ignore. But in those special cases I think it's helpful to explain what's actually happening to help the user understand it.
IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes:
LEGAL BOILERPLATE
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
EXTRA RESOURCES