Capture open transactions on disabled hubs#2319
Merged
mattjohnsonpint merged 5 commits intomainfrom Apr 21, 2023
Merged
Conversation
Contributor
Author
|
Note: After this is released, we can update troubleshooting docs at https://docs.sentry.io/platforms/dotnet/troubleshooting/#unhandled-exceptions-are-not-captured-when-using-an-async-main-method to just say to update the SDK version. |
This was referenced Apr 20, 2023
Contributor
Author
|
Docs pr: getsentry/sentry-docs#6707 |
SeanFeldman
approved these changes
Apr 21, 2023
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a subtle but important change to how transactions are managed with regard to disabled hubs.
Previously, if the hub was disabled (ie
SentrySdk.Initwas disposed) then no more transactions could be captured on that hub. This is a problem in the case where an unhandled exception occurs in anasync Main(or a top-level async main), because open transactions aren't marked as failed/aborted, but just not captured at all. The corresponding error event then has a Trace ID that can't be correlated to any transaction.With this change, we now prevent new transactions from being started after a hub is disabled (by ensuring they're sampled out). But we will go ahead and capture any that were already started before the hub was disabled.
This ultimately has the side effect of resolving #321 - fully working correctly with async main. The exception side of that was inadvertently resolved with #2103. This PR takes care of the associated transaction.
We can also now change our position on disposing from
SentrySdk.Init. In most cases you no longer need to dispose it, because we will flush automatically inAppDomainProcessExitIntegration. The reasons to still dispose are: if you have disabled that integration, or if you want to do unmonitored work after disabling Sentry, or if you are writing an integration that has its own lifetime events. Otherwise, disposing doesn't hurt, but it is no longer required. Comments are adjusted accordingly.We also had some strong wording about users not calling
CaptureTransactiondirectly, so I've hidden those with[EditorBrowsable(EditorBrowsableState.Never)]attributes.