-
-
Notifications
You must be signed in to change notification settings - Fork 226
Description
Package
Sentry
.NET Flavor
.NET
.NET Version
8.0
OS
iOS
SDK Version
4.10.1
Self-Hosted Sentry Version
No response
Steps to Reproduce
I am trying to migrate a .NET Maui app from AppCenter to Sentry. We were using AppCenter's Event logging extensively for analytics. I am trying to replace that with spans and breadcrumbs but I'm running into issues regarding global scope.
The app is offline capable, so it saves changes in a database and has a "sync queue" to make service calls if online, retry if unsuccessful, etc.
I'm instrumenting both user actions (button clicks) and the sync queue work for analytics and troubleshooting. To do so, I create transactions around every ICommand implementation and every run of the sync queue. Since I don't want to modify my whole codebase passing transactions/scopes to the service layer (for event logging), or database and api layer (for span creation), I am relying on setting the Scope's Transaction for the data layer to create its child spans. I'm using SentryHttpMessageHander to generate spans for api calls, which also relies on the Scopes Transaction.
Since both UI actions and background work happen at the same time, they override the current Scope Transaction and spans and breadcrumbs get logged to the wrong transaction, losing important data.
Reproducible Sample
- Clone demonstration https://github.com/MichaelLHerman/SentryMobileScope, change Sentry Dsn
- Run app targeting iOS simulator
- Click "Click Me" button several times in rapid succession
- Observe in Sentry that "remove" and "get" spans are being logged under the "test.ui.command" "click" transaction. "get" and "remove" are only being logged by the sync queue, they should only appear under the "send" transaction. "click" should only have "save"'s.
Expected Result
I think client apps need a way to have Global Scope turned off.
I'd like guidance on how to turn IsGlobalModeEnabled to false. I tried doing so and tried surrounding each transaction in a _hub.PushScope() / .Dispose() but from inspecting the variables in the debugger, it appeared that the Scope stack was not getting popped on dispose and was continuously increasing.
Actual Result
Metadata
Metadata
Assignees
Labels
Projects
Status
Status

