Set Up Profiling

With profiling, Sentry allows you to collect and analyze performance profiles from real user devices in production to give you a complete picture of how your application performs in a variety of environments.

Enable Profiling

To enable profiling, set the ProfilesSampleRate. Additionally, for all platforms except iOS/Mac Catalyst, you need to add a dependency on the Sentry.Profiling NuGet package.

Copied
dotnet add package Sentry.Profiling --prerelease

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

Copied
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;

    // 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;

    // 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)
    ));
});

Check out the performance setup documentation for more detailed information on how to configure sampling. Setting the traces sample rate to 1.0 means all transactions will be captured. Setting the profiles sample rate to 1.0 means all captured transactions will be profiled.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").