Skip to content

feat!: upgrade Sentry SDK to 7.1.0 - #218

Open
Thorstein Løkensgard (loekensgard) wants to merge 1 commit into
mainfrom
feat/sentry-7
Open

Thorstein Løkensgard (loekensgard) wants to merge 1 commit into
mainfrom
feat/sentry-7

Conversation

@loekensgard

Copy link
Copy Markdown
Member

Replaces #215, which bumped only Sentry.AspNetCore to 7.1.0 and left Sentry.Serilog at 6.12.1 - an unsupported mix, since NuGet unifies the Sentry core to 7.x while the 6.x sink runs against it.

What

  • Bumps Sentry.AspNetCore and Sentry.Serilog together from 6.13.0 to 7.1.0.
  • Reworks UseSentry: in Sentry 7 the Serilog sink no longer initializes the SDK (SentrySerilogOptions no longer derives from SentryOptions, and a DSN set on the sink fails at startup by design).

Design

The public contract is unchanged: DSN in the Sentry section gates initialization, everything else binds from the same section.

  • SentrySdk.Init runs from the extension, bound to the same configuration section, with the host environment as fallback (as before).
  • options.UseSerilog() applies Serilog LogContext properties to Sentry events from the first event (Sentry 7's documented flow).
  • A new internal SentryShutdownSink holds the init handle and rides Serilog's disposal pipeline: when the host disposes the logger, the SDK is flushed and closed. This restores the 6.x ownership model where the sink disposed the SDK.
  • The capture sink (WriteTo.Sentry) still binds its level settings from the same section.

The v7-native alternative (Sentry.Extensions.Hosting's UseSentry on the host builder) does not work from this extension point: UseIntilityLogging configures Serilog lazily from inside the UseSerilog callback, which runs after the host builder has snapshotted its service collection, so an IHostBuilder.ConfigureServices call from there is silently lost.

Consumer notes

  • Requests ending in 301, 305-399 or 401-404 are no longer traced by default (Sentry 7 default).
  • Removed SentryOptions config keys (EnableLogs, EnableMetrics, ...) are silently ignored.
  • Apps that initialize Sentry themselves (e.g. UseSentry from Sentry.AspNetCore) should not set a DSN in the Sentry section; Sentry warns about double initialization and the last init wins.

Tests

SentryLoggingTests covers the lifecycle end to end through the public seam (UseIntilityLogging + config): with a DSN the SDK initializes and closes with the host; without a DSN nothing initializes.

Bump Sentry.AspNetCore and Sentry.Serilog together to 7.1.0 and rework
UseSentry: the Serilog sink no longer initializes the SDK in Sentry 7,
so the extension initializes SentrySdk itself from the same
configuration section and closes it when the host disposes the logger.

BREAKING CHANGE: Sentry SDK major version 7. Requests ending in 301, 305-399
or 401-404 are no longer traced by default, and removed SentryOptions config
keys (EnableLogs, EnableMetrics, ...) are ignored. Apps that initialize
Sentry themselves should not set a DSN in the Sentry section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant