Commit 9d467f1
fix: UseSentry now initializes Sentry even when Logging.AddSentry ran first
The logging integration registers a non-initializing Func<IHub>, and the
initializing one was registered with TryAdd, so whichever ran first won. Calling
builder.Logging.AddSentry() before UseSentry therefore left the SDK disabled with
no indication, where v6 failed loudly at startup with "You must supply a DSN".
The initializing registration now replaces any existing accessor, so the order of
the two calls no longer matters. Tests cover both orders; the AddSentry-first one
fails without this change.
Calling both is still redundant and still registers two pairs of logger
providers, which is unchanged from v6.
Reported by Cursor Bugbot on #5595.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent dfcb80c commit 9d467f1
2 files changed
Lines changed: 53 additions & 1 deletion
File tree
- src/Sentry.Extensions.Logging/Extensions/DependencyInjection
- test/Sentry.AspNetCore.Tests
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
0 commit comments