Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 8 additions & 24 deletions docs/platforms/dotnet/common/profiling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dotnet add package Sentry.Profiling

Profiling depends on Sentry’s tracing product being enabled beforehand. To enable tracing in the SDK, set the `TracesSampleRate` option to the desired value.

```csharp {tabTitle:Windows/Linux/macOS}
```csharp
SentrySdk.Init(options =>
{
// ... usual setup options omitted for clarity (see Getting Started) ...
Expand All @@ -46,32 +46,16 @@ SentrySdk.Init(options =>
// We recommend adjusting this value in production.
options.ProfilesSampleRate = 1.0;

// Requires NuGet package: Sentry.Profiling
// Note: By default, the profiler is initialized asynchronously. This can be tuned by passing a desired initialization timeout to the constructor.
options.AddIntegration(new ProfilingIntegration(
// During startup, wait up to 500ms to profile the app startup code. This could make launching the app a bit slower so comment it out if your prefer profiling to start asynchronously
TimeSpan.FromMilliseconds(500)
));
});
```

```csharp {tabTitle:iOS/MacCatalyst}
SentrySdk.Init(options =>
{
// ... usual setup options omitted for clarity (see Getting Started) ...

// Sample rate for your transactions, e.g. value 0.1 means we want to report 10% of transactions.
// Setting 1.0 means all transactions are profiled.
// We recommend adjusting this value in production.
options.TracesSampleRate = 1.0;
// Attach the profiling integration.
options.AddProfilingIntegration();

// Sample rate for profiling, applied on top of othe TracesSampleRate,
// e.g. 0.2 means we want to profile 20 % of the captured transactions.
// We recommend adjusting this value in production.
options.ProfilesSampleRate = 1.0;
// On Windows, Linux, and macOS, the profiler is initialized asynchronously by default.
// Alternatively, you can switch to synchronous initialization by adding a timeout argument.
// The SDK waits up to the specified timeout for the .NET runtime profiler to start up before continuing.
// e.g. options.AddProfilingIntegration(TimeSpan.FromMilliseconds(500));
// Note: the timeout has no effect on iOS and MacCatalyst, which use native profiling and always start synchronously.
});
```

###

Check out the <PlatformLink to="/tracing/">tracing setup documentation</PlatformLink> for more detailed information on how to configure sampling.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ If you don't see any profiling data in [sentry.io](https://sentry.io), you can t
- Enable <PlatformLink to="/configuration/options/#debug">debug mode</PlatformLink> in the SDK and check the logs.
- If the transactions happen too soon after `Sentry.Init()`, they may not be captured yet.
This is because the `ProfilingIntegration()` from `Sentry.Profiling` NuGet package initializes asynchronously by default.
If you'd like to initialize it synchronously, set the desired timeout constructor argument, e.g. `new ProfilingIntegration(TimeSpan.FromMilliseconds(500))` to wait up to 500 ms for the profiler to start up.
Note: this doesn't apply to iOS and Mac Catalyst which use native profiling and are initialized synchronously.
If you'd like to initialize it synchronously, set the desired timeout argument, e.g. `options.AddProfilingIntegration(TimeSpan.FromMilliseconds(500))` to wait up to 500 ms for the profiler to start up.
Note: this doesn't apply to iOS and Mac Catalyst which use native profiling, are initialized synchronously, and the timeout argument is ignored.
- Maybe you're trying to capture profiles on a platform that is currently **not** supported, notably:
- .NET Framework; we only support .NET 6.0, .NET 7.0 and .NET 8.0
- Native AOT - this is only supported for iOS and Mac Catalyst (alongside the standard Mono AOT)
Expand Down
Loading