Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(.NET): Update migration guide for 4.x #9088

Merged
merged 9 commits into from
Feb 12, 2024
132 changes: 132 additions & 0 deletions docs/platforms/dotnet/migration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,138 @@ sidebar_order: 8000

Upgrading includes both breaking changes and new features.

## Migrating to 4.x

### .NET target framework changes
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved

We're dropping support for some of the old target frameworks, please check this [GitHub Discussion](https://github.com/getsentry/sentry-dotnet/discussions/2776) for details on why.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved

- Support for .NET Framework 4.6.1 has been replaced with 4.6.2
<br/>.NET Framework 4.6.1 was announced on Nov 30, 2015. And went out of support over a year ago, on Apr 26, 2022.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- Support for .NET Core 3.1 and .NET 5 has been dropped
- Support for netstandard2.0 for Sentry.AspNetCore has been dropped
- Support for .NET 6 on mobile (e.g: `net6.0-android`) has been replaced with .NET 7
<br/>.NET 6 on mobile has been out of support since May 2023 and with .NET 8, it's no longer possible to build .NET 6 Mobile specific targets. For that reason, we're moving the mobile-specific TFMs from `net6.0-platform` to `net7.0-platform`. Mobile apps still work on .NET 6 will pull the `Sentry` .NET 6, which offers the .NET-only features, without native/platform-specific bindings and SDKs. See [this ticket for more details](https://github.com/getsentry/sentry-dotnet/issues/2623).
- Support for MAUI Tizen has been dropped
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved

### Sentry Self-hosted Compatibility
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved

If you're using `sentry.io` this change does not affect you.
This SDK version is compatible with a self-hosted version of Sentry `22.12.0` or higher. If you are using an older version of [self-hosted Sentry](https://develop.sentry.dev/self-hosted/) (aka on-premise), you will need to [upgrade](https://develop.sentry.dev/self-hosted/releases/).

### Significant change in behavior
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved

- Transaction names for ASP.NET Core are now consistently named `HTTP-VERB /path` (e.g. `GET /home`). Previously, the leading forward slash was missing for some endpoints.
- Setting `SentryOptions.Dsn` to `null` now throws `ArgumentNullException` during initialization.
- Enable `CaptureFailedRequests` by default
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- Added `Sentry` namespace to global usings when `ImplicitUsings` is enabled
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
If you have conflicts, you can opt out by adding the following to your `csproj`:
```
<PropertyGroup>
<SentryImplicitUsings>false</SentryImplicitUsings>
</PropertyGroup>
```
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- Transactions' spans are no longer automatically finished with the status `deadline_exceeded` by the transaction. This is now handled by the [Relay](https://github.com/getsentry/relay).
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- Customers self hosting Sentry must use verion 22.12.0 or later
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- The `User.IpAddress` is now set to `{{auto}}` by default, even when sendDefaultPII is disabled
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- The "Prevent Storing of IP Addresses" option in the "Security & Privacy" project settings on sentry.io can be used to control this instead
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- The `DiagnosticLogger` signature for `LogWarning` changed to take the `exception` as the first parameter. That way it no longer gets mixed up with the TArgs.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved

### Breaking Changes

#### Changed APIs

- Class renamed `Sentry.User` to `Sentry.SentryUser`
- Class renamed `Sentry.Runtime` to `Sentry.SentryRuntime`
- Class renamed `Sentry.Span` to `Sentry.SentrySpan`
- Class renamed `Sentry.Transaction` to `Sentry.SentryTransaction`
- Class renamed `Sentry.Constants` to `Sentry.SentryConstants`
- Class renamed `Sentry.Context` to `Sentry.SentryContext`
- Class renamed `Sentry.Package` to `Sentry.SentryPackage`
- Class renamed `Sentry.Request` to `Sentry.SentryRequest`
- Class renamed `Sentry.` to `Sentry.SentryTransaction`
- Class renamed `Sentry.Session` to `Sentry.SentrySession`
- Class renamed `Sentry.Attachment` to `Sentry.SentryAttachment`
- Class renamed `Sentry.Hint` to `Sentry.SentryHint`
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- Interface renamed `Sentry.ISession` to `Sentry.SentryISession`
- Interface renamed `Sentry.IJsonSerializable` to `Sentry.SentryIJsonSerializable`
- Interface renamed `Sentry.ITransaction` to `Sentry.ITransactionTracer`.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- Rename iOS and MacCatalyst platform-specific options from `Cocoa` to `Native`
- Rename iOS platform-specific options `EnableCocoaSdkTracing` to `EnableTracing`
- Rename Android platform-specific options from `Android` to `Native`
- Rename Android platform-specific options `EnableAndroidSdkTracing` and `EnableAndroidSdkBeforeSend` to `EnableTracing` and `EnableBeforeSend` respectively
- Rename iOS and MacCatalyst platform-specific options from `iOS` to `Cocoa`
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- `DebugImage` and `DebugMeta` moved to `Sentry.Protocol` namespace.
- `SentryClient.Dispose` is no longer obsolete
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- `ISentryClient.CaptureEvent` overloads have been replaced by a single method accepting optional `Hint` and `Scope` parameters. You will need to pass `hint` as a named parameter from code that calls `CaptureEvent` without passing a `scope` argument.
- `TransactionContext` and `SpanContext` constructors were updated. If you're constructing instances of these classes, you will need to adjust the order in which you pass parameters to these.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- The `DiagnosticLogger` signature for `LogError` and `LogFatal` changed to take the `exception` as the first parameter. That way it no longer gets mixed up with the TArgs. The `DiagnosticLogger` now also receives an overload for `LogError` and `LogFatal` that accepts a message only.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- `Distribution` added to `IEventLike`.
- `StackFrame`'s `ImageAddress`, `InstructionAddress`, and `FunctionId` changed to `long?`.
- `DebugImage.ImageAddress` changed to `long?`.
- Contexts now inherit from `IDictionary` rather than `ConcurrentDictionary`. The specific dictionary being used is an implementation detail.
- The method used to configure a Sentry Sink for Serilog now has an additional overload. Calling `WriteTo.Sentry()` with no arguments will no longer attempt to initialize the SDK (it has optional arguments to configure the behavior of the Sink only). If you want to initialize Sentry at the same time you configure the Sentry Sink then you will need to use the overload of this method that accepts a DSN as the first parameter (e.g. `WriteTo.Sentry("https://[email protected]:65535/2147483647")`).
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved

#### Removed APIs

- SentrySinkExtensions.ConfigureSentrySerilogOptions is now internal. If you were using this method, please use one of the `SentrySinkExtensions.Sentry` extension methods instead.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- A number of `[Obsolete]` options have been removed
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- `BeforeSend` - use `SetBeforeSend` instead.
- `BeforeSendTransaction` - use `SetBeforeSendTransaction` instead.
- `BeforeBreadcrumb` - use `SetBeforeBreadcrumb` instead.
- `CreateHttpClientHandler` - use `CreateHttpMessageHandler` instead.
- `ReportAssemblies` - use `ReportAssembliesMode` instead.
- `KeepAggregateException` - this property is no longer used and has no replacement.
- `DisableTaskUnobservedTaskExceptionCapture` method has been renamed to `DisableUnobservedTaskExceptionCapture`.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- `DebugDiagnosticLogger` - use `TraceDiagnosticLogger` instead.
- A number of iOS/Android-specific `[Obsolete]` options have been removed
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- `Distribution` - use `SentryOptions.Distribution` instead.
- `EnableAutoPerformanceTracking` - use `SetBeforeSendTransaction` instead.
- `EnableCoreDataTracking` - use `EnableCoreDataTracing` instead.
- `EnableFileIOTracking` - use `EnableFileIOTracing` instead.
- `EnableOutOfMemoryTracking` - use `EnableWatchdogTerminationTracking` instead.
- `EnableUIViewControllerTracking` - use `EnableUIViewControllerTracing` instead.
- `StitchAsyncCode` - no longer available.
- `ProfilingTracesInterval` - no longer available.
- `ProfilingEnabled` - use `ProfilesSampleRate` instead.
- Obsolete `SystemClock` constructor removed, use `SystemClock.Clock` instead.
- Obsolete `Runtime.Clone()` removed, this shouldn't have been public in the past and has no replacement.
- Obsolete `SentryException.Data` removed, use `SentryException.Mechanism.Data` instead.
- Obsolete `AssemblyExtensions` removed, this shouldn't have been public in the past and has no replacement.
- Obsolete `SentryDatabaseLogging.UseBreadcrumbs()` removed, it is called automatically and has no replacement.
- Obsolete `Scope.GetSpan()` removed, use `Span` property instead.
- Obsolete `IUserFactory` removed, use `ISentryUserFactory` instead.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- `IHasMeasurements` has been removed, use `ISpanData` instead.
- `IHasBreadcrumbs` has been removed, use `IEventLike` instead.
- `ISpanContext` has been removed, use `ITraceContext` instead.
- `IHasTransactionNameSource` has been removed, use `ITransactionContext` instead.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- The unused `StackFrame.InstructionOffset` has been removed.
- The unused `Scope.Platform` property has been removed.
- The obsolete setter `Sentry.PlatformAbstractions.Runtime.Identifier` has been removed
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- `Sentry.Values<T>` is now internal as it is never exposed in the public API
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- The `TracePropagationTarget` class has been removed, use the `SubstringOrRegexPattern` class instead.
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
- The `WithScope` and `WithScopeAsync` methods have been removed. We have discovered that these methods didn't work correctly in certain desktop contexts, especially when using a global scope.
<br/>Replace your usage of `WithScope` with overloads of `Capture*` methods:
- `SentrySdk.CaptureEvent(SentryEvent @event, Action<Scope> scopeCallback)`
- `SentrySdk.CaptureMessage(string message, Action<Scope> scopeCallback)`
- `SentrySdk.CaptureException(Exception exception, Action<Scope> scopeCallback)`

```c#
// Before
SentrySdk.WithScope(scope =>
{
scope.SetTag("key", "value");
SentrySdk.CaptureEvent(new SentryEvent());
});

// After
SentrySdk.CaptureEvent(new SentryEvent(), scope =>
{
// Configure your scope here
scope.SetTag("key", "value");
});
```

## Migrating to 3.12.0

### NuGet Changes
Expand Down
Loading