I am working with the .NET SDK, and we are currently on 2.1.4 (the latest at the time our app was released).
I gather that there is such a thing as a global scope, but it does not appear that we are creating it, since I also gather that any logging captured on threads would inherit anything applied on the global scope, such as Scope.User
, Scope.Contexts.*
, tags, and (I hope) breadcrumbs. Is this correct?
I found one forum post (Scopes and multithreading in python) talking about Hub
, and ways to get unambiguously to the global scope. But Hub
doesn’t seem to be much of a thing in this .NET version.
So really two questions, and an answer to either would suffice.
- On what thread or in what way can we configure scope such that it WOULD be the global one (assuming my idea of global scope is even a thing, where certain core data would always be set, after being set once, across the whole application)?
- How can it be accessed from elsewhere (threadwise) and added to, such that the data remains present for all logging? I assume
SentrySdk.WithScope
would be the way to use it, or some clone of it?
Currently, for both Android and iOS (but .NET by way of Xamarin), we call ConfigureScope
on the main UI thread. But many things happen on other threads that we expect to accumulate breadcrumbs, or if errors are logged there we expect to reflect all the breadcrumbs and basic global info.
Should we just retain the scope instance coming off of ConfigureScope
, regardless of whether it’s “global” or not, and then use it with WithScope
everywhere we want the info to carry across? I feel like this should be clear enough but somehow I’m failing to search using the right language I guess, or what I’m finding doesn’t seem to apply to the .NET SDK, or is ambiguous from docs.