github getsentry/sentry-dotnet 7.0.0-rc.2

pre-release2 hours ago

Version 7 of the Sentry SDK for .NET adds support for .NET 11 and gives Sentry a single place to be initialized. It contains breaking changes, so read the upgrade notes below before you upgrade.

This is a release candidate, built against .NET 11 RC 2.

Highlights

  • .NET 11. The SDK targets net11.0 alongside .NET 8, 9 and 10, including Android, iOS and Mac Catalyst apps on .NET 11, with support for its new Android assembly store format and Zstandard-compressed assemblies.
  • One place to initialize Sentry. The Microsoft.Extensions.Logging, Serilog, NLog and log4net integrations now only capture logs, breadcrumbs and events; they no longer start the SDK. Initialize Sentry with SentrySdk.Init or UseSentry, and configure it from the Sentry section of appsettings.json.
  • UseSentry for generic host apps. The new Sentry.Extensions.Hosting package adds UseSentry to Host.CreateApplicationBuilder and IHostBuilder, for worker services, console apps, Azure Functions (isolated) and Windows services. ASP.NET Core apps can call builder.UseSentry(...) on WebApplicationBuilder and keep chaining.
  • Cron monitors from code. SentrySdk.WithMonitor and SentrySdk.WithMonitorAsync run a job, send its check-ins, and can create the monitor along with its schedule. Hangfire recurring jobs marked with [SentryMonitorSlug] send their cron schedule automatically.
  • Less noise in tracing. Requests that end in 301, 305–399 or 401–404 are no longer traced by default.
  • The right environment everywhere. ASP.NET Core, generic host apps, Blazor WebAssembly and Google Cloud Functions take the Sentry environment from the host environment, and logs, metrics, sessions and check-ins use an environment set on the scope.

Upgrading from 6.x

Target frameworks

  • Mobile targets require .NET 10 or later: net9.0-android, net9.0-ios, net9.0-maccatalyst and net9.0-windows are no longer supported.
  • On .NET 11, the minimum Android API level is 24 (Android 7.0) and the minimum Mac Catalyst version is 17.0.
  • Other targets are unchanged: .NET 8 and later, .NET Standard 2.0 and 2.1, and .NET Framework 4.6.2.

Initializing Sentry

  • Serilog's WriteTo.Sentry(...), NLog's Sentry target, log4net's SentryAppender and Logging.AddSentry(...) no longer initialize the SDK. Initialize Sentry first with SentrySdk.Init, or UseSentry in ASP.NET Core, MAUI, Blazor WebAssembly and generic host apps, and move Dsn, Release, Environment and other SDK settings there. A DSN still set on one of these integrations fails with a message explaining what to change (to prevent SDK users being blind-sided by this change).
  • Logging:Sentry in appsettings.json now only sets log levels: MinimumEventLevel, MinimumBreadcrumbLevel and the LogLevel rules. Move any other key to the Sentry section; the app fails at startup until you do.
  • SentryLoggingOptions, SentrySerilogOptions and SentryNLogOptions no longer derive from SentryOptions. Serilog's ApplySerilogScopeToEvents() is renamed UseSerilog().
  • NLog flushes Sentry using SentryOptions.FlushTimeout, which defaults to 2 seconds. The NLog target used to wait up to 15.
  • Logging.AddSentry() no longer registers IHub, ISentryClient or Func<IHub> in the service collection; UseSentry does. An app that initializes Sentry with SentrySdk.Init and injects them now fails when they're resolved. Switch to UseSentry, or register HubAdapter.Instance for each type yourself.
  • In an app that calls both UseSentry and Logging.AddSentry(), the Logging.AddSentry() call now does nothing. Move its settings to the host's options, such as SentryAspNetCoreOptions, and remove the call.
  • In MAUI, options set in the UseSentry callback now override appsettings.json, as they do in ASP.NET Core.

Removed and changed APIs

  • SentryOptions.EnableLogs is removed. With SentrySdk.Init and the logging integrations, logs are always sent; drop them with SetBeforeSendLog(_ => null). ASP.NET Core, MAUI and Blazor WebAssembly keep the opt-in: set EnableLogs on their options or in the Sentry section, as in 6.x.
  • SentryOptions.EnableMetrics is removed. Return null from SetBeforeSendMetric to drop metrics.
  • Scope.Release, Scope.Distribution and SentryOptions.ApplyDefaultTags are removed. Set Release and Distribution on SentryOptions. DefaultTags are still applied.
  • SentryOptions.ScopeObserver, EnableScopeSync and CrashedLastRun are now internal.
  • On iOS and Mac Catalyst, SentryOptions.Native.EnableAppHangTrackingV2 is removed; use EnableAppHangTracking. SentryOptions.Native.AddInAppExclude(string), which had no effect, is removed too.
  • Envelope.FromEvent, Envelope.FromFeedback and Envelope.FromTransaction take the IDiagnosticLogger as their last parameter.
  • The OTLP exporter no longer sets a global OpenTelemetry propagator, and its defaultTextMapPropagator parameter is removed. The propagator should be configured via the OpenTelemetry SDK instead. Sentry.OpenTelemetry and Sentry.OpenTelemetry.Exporter now require OpenTelemetry 1.12.0 or later.

Changes in behavior

  • Requests that end in 301, 305–399 or 401–404 are no longer traced. To trace them again, call options.TraceIgnoreStatusCodes.Clear().
  • Apps that use the ISentryBuilder overloads of UseSentry (including gRPC apps), Blazor WebAssembly or Google Cloud Functions, and don't set an environment, now report the host environment, such as development or staging, instead of production. Update alerts and filters that rely on the old value.
  • Events, transactions, logs and metrics report the SDK name of the integration that initialized Sentry, such as sentry.dotnet.aspnetcore, rather than the logging integration that captured them.
  • On Android and iOS, SENTRY_RELEASE takes precedence over the release derived from the app package.
  • Hangfire recurring jobs marked with [SentryMonitorSlug] send their schedule and time zone, which updates existing monitors on the next run. To keep managing schedules in Sentry, opt out with UseSentry(o => o.SendMonitorConfig = false).

Breaking Changes 🛠

  • builder.Logging.AddSentry() no longer registers IHub, ISentryClient or Func<IHub> in the service collection. UseSentry registers them; apps that initialize Sentry with SentrySdk.Init and inject them now register them themselves by @jamescrosswell in #5740
  • fix(maui)!: options set in UseSentry now take precedence over appsettings.json by @jamescrosswell in #5658
  • The Microsoft.Extensions.Logging integration no longer initializes the SDK. Sentry must now be initialized separately from the logging integration (using SentrySdk.Init or UseSentry) by @jamescrosswell in #5595
  • Sentry's logging configuration section (Logging:Sentry) now only configures the logging integration. Core SDK settings there, such as Dsn, no longer have any effect and fail at startup with migration guidance: move them to the Sentry section, or pass them where Sentry is initialized by @jamescrosswell in #5595
  • Blazor WebAssembly's logger now respects the MinimumEventLevel, MinimumBreadcrumbLevel, log entry filters and ConfigureScope callbacks set in UseSentry by @jamescrosswell in #5595
  • feat(log4net)!: the Sentry appender no longer initializes the SDK by @jamescrosswell in #5592
  • feat(nlog)!: the Sentry target no longer initializes the SDK by @jamescrosswell in #5585
  • feat(serilog)!: the Sentry sink no longer initializes the SDK by @jamescrosswell in #5573
  • feat!: set the Sentry environment from the host environment in every ASP.NET Core UseSentry overload, Blazor WebAssembly and Google Cloud Functions by @jamescrosswell in #5703
  • fix!: apps that call both UseSentry and Logging.AddSentry() no longer capture each error, breadcrumb and log twice by @jamescrosswell in #5694
  • feat!: remove SentryOptions.EnableMetrics by @ric-oliv in #5690
  • feat!: EnableLogs moves from SentryOptions to ASP.NET Core, MAUI and Blazor, where logs are opt-in by @ric-oliv in #5642
  • Scope.Release and Scope.Distribution have been removed, and Release and Distribution have moved from IEventLike to ITransactionData. Set them on SentryOptions instead. by @jamescrosswell in #5671
  • SentryOptions.ApplyDefaultTags has been removed. Default tags set in SentryOptions.DefaultTags are still applied to events and transactions. by @jamescrosswell in #5671
  • Logs, metrics, sessions, check-ins and trace propagation now use an environment set on the scope, as events already did. Setting Scope.Environment to null clears the override. by @jamescrosswell in #5671
  • Events, transactions, logs and metrics all report the SDK name of the integration that initialized Sentry, such as sentry.dotnet.aspnetcore. Blazor WebAssembly now reports sentry.dotnet.aspnetcore.blazor.webassembly. by @jamescrosswell in #5671
  • On Android and iOS, SENTRY_RELEASE now takes precedence over the default release derived from the app package. by @jamescrosswell in #5671
  • Envelope.FromEvent, Envelope.FromFeedback and Envelope.FromTransaction now take the IDiagnosticLogger as their last parameter, after attachments (and sessionUpdate). This only affects code that creates envelopes directly and passes these arguments positionally; those calls no longer compile, so reorder the arguments or pass them by name. by @jamescrosswell in #5669
    // Before
    Envelope.FromEvent(@event, logger, attachments, sessionUpdate);
    Envelope.FromTransaction(transaction, logger, attachments);
    
    // After
    Envelope.FromEvent(@event, attachments, sessionUpdate, logger);
    Envelope.FromTransaction(transaction, attachments, logger);
  • Removed SentryOptions.Native.EnableAppHangTrackingV2 on iOS and Mac Catalyst (use EnableAppHangTracking instead) by @jamescrosswell in #5654
  • Removed SentryOptions.Native.AddInAppExclude(string) on iOS, which had no effect by @jamescrosswell in #5654
  • feat!: don't trace 301, 305-399 or 401-404 responses by default by @jamescrosswell in #5632
  • feat!: SentryOptions.ScopeObserver, EnableScopeSync and CrashedLastRun are now internal by @jamescrosswell in #5631
  • feat!: stop deserializing "critical" breadcrumb level by @jamescrosswell in #5630

Features ✨

  • Hangfire recurring jobs marked with [SentryMonitorSlug] now send their cron schedule and time zone with the check-in, so Sentry creates the monitor if it doesn't exist yet. This is on by default: on upgrade, existing monitors take their schedule and time zone from the recurring job on its next run (other monitor settings are kept). To keep managing schedules in Sentry, opt out with UseSentry(o => o.SendMonitorConfig = false). by @wedamija in #5665
  • feat(aspnetcore): add UseSentry overloads on WebApplicationBuilder by @ric-oliv in #5720
  • feat(otel): raise the OpenTelemetry floor to 1.12.0 by @jamescrosswell in #5560
  • feat: add support for .NET 11 RC 2 by @jamescrosswell in #5725
  • feat: add Sentry.Extensions.Hosting with UseSentry for generic host apps by @ric-oliv in #5739
  • feat: add SentrySdk.WithMonitor to run a job with cron check-ins and create the monitor from code by @wedamija in #5664
  • feat: Support reading .NET 11 Android assembly stores by @jamescrosswell in #5577
  • feat: Support Zstandard-compressed assemblies on Android (.NET 11) by @jamescrosswell in #5575
  • feat: add support for .NET 11 RC 1 by @jamescrosswell in #5566
  • feat: Accept Android assembly store v4 versions by @jamescrosswell in #5574
  • feat: Logs are always enabled and SentryOptions.EnableLogs is ignored by @jamescrosswell in #5504
  • Support for .NET 11 by @jamescrosswell in #5529
  • Mobile targets now require .NET 10 or later - net9.0-android, net9.0-ios, net9.0-maccatalyst and net9.0-windows have been dropped. by @jamescrosswell in #5529
  • On .NET 11 the minimum Android API level is now 24 (Android 7.0) and the minimum MacCatalyst version is 17.0. by @jamescrosswell in #5529
  • Non-mobile targets continue to support .NET 8 and later. by @jamescrosswell in #5529

Fixes 🐛

  • fix(maui): report in_foreground for apps using the UIScene lifecycle by @jamescrosswell in #5730
  • fix(aspnetcore): start the SDK when the host starts, not on the first request by @ric-oliv in #5721
  • fix(otlp): don't configure an automatic OTel propagator by @jamescrosswell in #5319
  • fix: upload symbols and create releases when publishing Native AOT with the .NET 11 SDK by @jamescrosswell in #5731
  • fix: don't upload pre-trim PDBs for trimmed iOS and Mac Catalyst builds by @jamescrosswell in #5732
  • fix: avoid first-chance exception when getting length of non-seekable attachment streams by @bitsandfoxes in #5736

Dependencies ⬆️

Deps

  • chore(deps): update Native SDK to v0.17.4 by @github-actions in #5743
  • chore(deps): update Java SDK to v8.61.0 by @github-actions in #5734
  • chore(deps): update Cocoa SDK to v9.30.2 by @github-actions in #5735
  • chore(deps): update Native SDK to v0.17.3 by @github-actions in #5717

Don't miss a new sentry-dotnet release

NewReleases is sending notifications on new releases.