---
title: "Profiling"
description: "Learn how to enable profiling in your app if it is not already set up."
url: https://docs.sentry.io/platforms/dotnet/profiling/
---

# Set Up .NET Profiling | Sentry for .NET

With [profiling](https://docs.sentry.io/product/explore/profiling.md), 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.

Sentry profiling for .NET is available in *Alpha* on .NET 8.0+ for:

* Windows
* Linux
* macOS
* iOS
* Mac Catalyst

## [Enable Profiling](https://docs.sentry.io/platforms/dotnet/profiling.md#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.

```shell
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
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 other 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;

    // Attach the profiling integration.
    options.AddProfilingIntegration();

    // 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 [tracing setup documentation](https://docs.sentry.io/platforms/dotnet/tracing.md) 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.

## Pages in this section

- [Troubleshooting](https://docs.sentry.io/platforms/dotnet/profiling/troubleshooting.md)
