Repository navigation
Conversation
…s twice Each Logging.AddSentry() call registered its own pair of providers, so an app that calls it twice, for example from Program.cs and from a shared setup helper, sent every event, breadcrumb and structured log twice. AddSentry() now keeps the provider registrations it added and skips them while they're still registered. A ClearProviders() between two calls removes them, so the next call adds them again. Options, configuration binding and filter rules are still registered on every call, so each call's options still apply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fix/logging-addsentry-after-clearproviders #5786 +/- ##
==============================================================================
+ Coverage 76.22% 76.23% +0.01%
==============================================================================
Files 528 529 +1
Lines 19307 19326 +19
Branches 3734 3736 +2
==============================================================================
+ Hits 14716 14734 +18
- Misses 3734 3735 +1
Partials 857 857 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Calling
builder.Logging.AddSentry()more than once now adds Sentry's logger providers once. Until now each call registered its own pair, so an app that calls it fromProgram.csand from a shared setup helper sent every event, breadcrumb and structured log twice. That already happened withoutUseSentry, and #5776 opened a second way in: afterUseSentryandClearProviders(), each call rebuilds the host's providers.AddSentry()now keeps the provider registrations it added, likeHostLoggerProvidersdoes, and skips them while they're still in the service collection. AClearProviders()between two calls removes them, so the next call adds them again. Everything else is still registered on every call, so the options passed to each call still apply, in the same order as before.Found while reviewing #5776, and stacked on it.