---
title: "OpenTelemetry Support"
description: "Using OpenTelemetry with Sentry Performance."
url: https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker/tracing/instrumentation/opentelemetry/
---

# OpenTelemetry Support | Sentry for Azure Functions

You can configure your [OpenTelemetry SDK](https://opentelemetry.io/) to send traces and spans to Sentry.

## [Install](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker/tracing/instrumentation/opentelemetry.md#install)

The `Sentry.OpenTelemetry` package requires `OpenTelemetry` package `1.5.0` or higher.

To install, add the `Sentry` and `Sentry.OpenTelemetry` **NuGet** packages to your project:

```shell
dotnet add package Sentry -v 6.3.0
dotnet add package Sentry.OpenTelemetry -v 6.3.0
```

If you're building an ASP.NET or ASP.NET Core application, add their respective packages (`Sentry.AspNet` or `Sentry.AspNetCore`) as well.

## [Usage](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker/tracing/instrumentation/opentelemetry.md#usage)

To start tracing, you'll need to add Sentry to the tracer provider. This will make it possible for OpenTelemetry spans to be captured by Sentry.

```csharp
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .AddSource(serviceName) // <-- The name of an activity sources you care about
    .AddSentry() // <-- Configure OpenTelemetry to send traces to Sentry
    .Build();
```

Next, initialize Sentry and opt into the use of OpenTelemetry. This allows the SDK to send OpenTelemetry spans to Sentry.

```csharp
SentrySdk.Init(options =>
{
    // options.Dsn = "... Your DSN ...";
    // options.SendDefaultPii = true;
    options.TracesSampleRate = 1.0;
    options.UseOpenTelemetry(); // <-- Configure Sentry to use OpenTelemetry trace information
});
```

## [OpenTelemetry and Sentry](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker/tracing/instrumentation/opentelemetry.md#opentelemetry-and-sentry)

With Sentry’s OpenTelemetry SDK, an OpenTelemetry `Span` becomes a Sentry `Transaction` or `Span`. The first `Span` sent through the Sentry `SpanProcessor` is a `Transaction`, and any child `Span` gets attached to the first `Transaction` upon checking the parent `Span` context. This is true for the OpenTelemetry root `Span` and any top level `Span` in the system. For example, a request sent from frontend to backend will create an OpenTelemetry root `Span` with a corresponding Sentry `Transaction`. The backend request will create a new Sentry `Transaction` for the OpenTelemetry `Span`. The Sentry `Transaction` and `Span` are linked as a trace for navigation and error tracking purposes.

### [Capturing exceptions](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker/tracing/instrumentation/opentelemetry.md#capturing-exceptions)

OpenTelemetry in .NET is implemented via the System.Diagnostics.Activity namespace. However, not all of the functionality in that namespace is supported by OpenTelemetry. In particular, it is [not recommended](https://github.com/open-telemetry/opentelemetry-specification/pull/4333) that you use the `Activity.RecordException` or `Activity.AddException` methods. Using either of these methods will result in valuable **information being removed from exceptions** before these get captured by Sentry.

Instead you should either log the exceptions (using `ILogger`) or capture the exceptions directly using `SentrySdk.CaptureException`.

## [Additional Configuration](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker/tracing/instrumentation/opentelemetry.md#additional-configuration)

If you need more fine grained control over Sentry, take a look at the [Configuration page](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker/configuration.md). In case you'd like to filter out transactions before sending them to Sentry (to get rid of health checks, for example), you may find the [Filtering page](https://docs.sentry.io/platforms/dotnet/guides/azure-functions-worker/configuration/filtering.md#filtering-transaction-events) helpful.
