---
title: "OpenTelemetry Support"
description: "Using OpenTelemetry with Sentry Performance."
url: https://docs.sentry.io/platforms/go/guides/negroni/tracing/instrumentation/opentelemetry/
---

# OpenTelemetry Support | Sentry for Negroni

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

## [Install](https://docs.sentry.io/platforms/go/guides/negroni/tracing/instrumentation/opentelemetry.md#install)

OpenTelemetry integration was added in `sentry-go` version 0.18.0, and works only for Go >= 1.18.

The Sentry Go OpenTelemetry integration requires `go.opentelemetry.io/otel` (and its submodules), version `1.11.0` or higher.

Install the `otel` module in addition to the main SDK:

```bash
go get github.com/getsentry/sentry-go \
       github.com/getsentry/sentry-go/otel
```

## [Usage](https://docs.sentry.io/platforms/go/guides/negroni/tracing/instrumentation/opentelemetry.md#usage)

You need to register the Sentry-provided SpanProcessor and Propagator as shown below:

```go
import (
	"go.opentelemetry.io/otel"
	sdktrace "go.opentelemetry.io/otel/sdk/trace"

	"github.com/getsentry/sentry-go"
	sentryotel "github.com/getsentry/sentry-go/otel"
	// ...
)

sentry.Init(sentry.ClientOptions{
	Dsn:              "___PUBLIC_DSN___",
	EnableTracing:    true,
	TracesSampleRate: 1.0,
	Debug:            true,
})

tp := sdktrace.NewTracerProvider(
	sdktrace.WithSpanProcessor(sentryotel.NewSentrySpanProcessor()),
)
otel.SetTracerProvider(tp)
otel.SetTextMapPropagator(sentryotel.NewSentryPropagator())
```

Now, all spans produced by OpenTelemetry will also be captured and sent to Sentry.

### [Linking Errors to Transactions](https://docs.sentry.io/platforms/go/guides/negroni/tracing/instrumentation/opentelemetry.md#linking-errors-to-transactions)

If you want the errors and messages the SDK produces (for example, via `CaptureException` or `CaptureMessage`) to be linked to transactions in the UI, a couple of extra steps are required. Most importantly, the current OpenTelemetry-enhanced context has to be passed as part of `EventHint` to `client.Capture*` methods:

```go
hub := sentry.CurrentHub()
//// or:
// hub := sentry.GetHubFromContext(ctx)
client, scope := hub.Client(), hub.Scope()
client.CaptureException(
	errors.New("new error"),
	&sentry.EventHint{Context: ctx},
	scope,
)
```

Events captured with the high-level `sentry.CaptureException` or `sentry.CaptureMessage` functions are NOT linked to transactions or spans at the moment. This will be improved in future releases.

## [OpenTelemetry and Sentry](https://docs.sentry.io/platforms/go/guides/negroni/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.

## [Additional Configuration](https://docs.sentry.io/platforms/go/guides/negroni/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/go/guides/negroni/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/go/guides/negroni/configuration/filtering.md#filtering-transaction-events) helpful.
