-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
Make Scope data global on desktop and mobile #628
Comments
Hello @bruno-garcia, I was hit by the same issue and I must say it took me time to figure out what was going on (and get the source code). It's really counter-intuitive. I wanted to track events and I was receiving them through different callbacks on different threads. As a workaround I ended up creating a specific scope that I use as a container for my events: private readonly BaseScope _breadCrumbsScope = new Scope(null); When I need to report an exception I fill everything I need just before sending it so I'm sure it's on the good scope: SentrySdk.ConfigureScope(scope =>
{
foreach (var breadCrumb in _breadCrumbsScope.Breadcrumbs)
{
scope.AddBreadcrumb(message: breadCrumb.Message, category: breadCrumb.Category, type: breadCrumb.Type, data: (Dictionary<string, string>)breadCrumb.Data, level: breadCrumb.Level);
}
});
// Fill other things like user info and meta data
SentrySdk.CaptureException(exception); As a side note, I do not use the embedded exception handling. |
Thanks for sharing your work around @jairbubbles and sorry you hit this issue and took time to trace down. We'll hopefully get to this soon with a solution. |
Customers also have the need to change data globally outside desktop apps. When they want to add such tags for data that's resolved only later in the program's executing. After a call to the backend for example that runs parallel to the process bootstrapping. |
In my case I wouldn't mind managing the global scope on my own, exposing static functions is nice but can be misleading. |
We solved "Global Mode" on version 3.8.1. It makes it so that any call to You can opt-in to this mode through:
To clarify: This options doesn't make sense in any sort of web server where each individual request takes a separate scope (You want each We plan to ship |
This came up a few times, more recently on SO:
https://stackoverflow.com/questions/65066020/c-xamarin-forms-and-sentrysdk-context-info-not-making-it-to-sentry-errors
Currently the Hub is stored in a AsyncLocal field so data forks on new asynchronous flows.
This causes problems for Desktop and Mobile apps that want to push work to a back ground thread but would like that data available in case of an error anywhere.
This is how the Android and iOS SDKs of Sentry work, with a static global Hub.
An attempt to simulate that happened in this PR #448 but we the general approach needs to be discussed.
Resolves: #221
More context: https://forum.sentry.io/t/accessing-and-ensuring-global-shared-scope-in-net/11709/2
The text was updated successfully, but these errors were encountered: