Repository navigation
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## version7 #5776 +/- ##
============================================
+ Coverage 76.17% 76.22% +0.04%
============================================
Files 526 528 +2
Lines 19265 19307 +42
Branches 3729 3734 +5
============================================
+ Hits 14676 14716 +40
Misses 3734 3734
- Partials 855 857 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
After UseSentry and then ClearProviders(), Logging.AddSentry() found the leftover marker, installed NullLoggerProviders and warned that the call was redundant, so reordering the calls was the only fix. Host integrations now register their providers through HostLoggerProviders, which keeps the factories and the descriptors it added. AddSentry() checks the captured service collection for those descriptors and, when the app removed them, rebuilds the host's own providers. The host's options and the filters that target its provider types keep applying, including the ASP.NET Core rule for errors logged by UseExceptionHandler. Refs #5755 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ric-oliv
force-pushed
the
fix/logging-addsentry-after-clearproviders
branch
from
October 23, 2026 08:54
479b8a6 to
f8fb00e
Compare
…Logging.AddSentry() Logging.AddSentry() rebuilds ASP.NET Core's providers because the generic host's providers step aside. Only a unit test with substitute providers covered that, so this runs it on a real WebApplication in both registration orders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four tests spelled out ConfigureServices(services => services.AddLogging(logging => logging.AddSentry())). LoggingAddSentry() reads like the ClearLoggerProviders() step next to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
After
UseSentryand thenClearProviders(),builder.Logging.AddSentry()now adds back the logger providers thatUseSentryregistered, sologger.LogError(...)reaches Sentry again. Until now,AddSentry()saw the marker thatClearProviders()left behind, installed twoNullLoggerProviders and logged a warning telling people to remove the call. Reordering the calls was the only way out.AddSentry()rebuilds the host's own providers rather than falling back to the plainSentryLoggerProviderpair. That way the host's options still apply, such asMinimumEventLevelset inUseSentry, and so do the filter rules that target the host's provider types, whichClearProviders()doesn't remove. In ASP.NET Core, one of those rules keeps the logger from capturing exceptions thatUseExceptionHandlerlogs, soSentryMiddlewarereports them with the right mechanism (#1284). Rebuilding the ASP.NET Core provider also starts the SDK duringBuild(), the same as without the clear.To make that possible, each host integration now registers its providers through
HostLoggerProviders, which replacesHostLoggerProvidersMarker. It keeps the provider factories and the exact descriptors it added. WhenAddSentry()'s providers are created, it checks the captured service collection for those descriptors, so callingAddSentry()beforeUseSentrystill sends each error once. ASP.NET Core, Google Cloud Functions and MAUI now register their providers through factories instead of by type, and no extra provider joins the logging pipeline.Two smaller changes, both logged through the SDK's diagnostic logger:
AddSentry()no longer tells people to remove the call. It says the call has no effect and its options are ignored.AddSentry()are ignored because it rebuilt the host's providers.Apps that send logs through NLog or log4net and don't call
Logging.AddSentry()are unaffected.UseSentryfollowed byClearProviders()withoutAddSentry()still drops theILoggerintegration without a word. A diagnostic warning for that comes next.This is part 2 of the plan in #5755. It builds on #5772, which starts the SDK during
Build().Refs #5755