# OpenTelemetry Protocol (OTLP)

Sentry can ingest [OpenTelemetry](https://opentelemetry.io) traces and logs directly via the [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otel/protocol/). Sentry does not support ingesting OTLP metrics.

## [OpenTelemetry Traces](https://docs.sentry.io/concepts/otlp.md#opentelemetry-traces)

This feature is currently in open beta. Please reach out to <feedback-tracing@sentry.io> if you have feedback or questions. Features in beta are still in-progress and may have bugs. We recognize the irony.

If you have an existing OpenTelemetry trace instrumentation, you can configure your OpenTelemetry exporter to send traces to Sentry directly. Sentry's OTLP ingestion traces endpoint is currently in development, and has a few known limitations:

* Span events are not supported. All span events are dropped during ingestion.
* Span links are partially supported. We ingest and display span links, but they cannot be searched, filtered, or aggregated. Links are shown in the [Trace View](https://docs.sentry.io/concepts/key-terms/tracing/trace-view.md).
* Array attributes are partially supported. We ingest and display array attributes, but they cannot be searched, filtered, or aggregated. Array attributes are shown in the [Trace View](https://docs.sentry.io/concepts/key-terms/tracing/trace-view.md).

You can find the values of Sentry's OTLP traces endpoint and public key in your Sentry project settings.

1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry.
2. Select a project from the list.
3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading.

The easiest way to configure an OpenTelemetry exporter is with environment variables. You'll need to configure the trace endpoint URL, as well as the authentication headers. Set these variables on the server where your application is running.

`.env`

```bash
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="___OTLP_TRACES_URL___"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-sentry-auth=sentry sentry_key=___PUBLIC_KEY___"
```

If you prefer to explicitly configure an OpenTelemetry SDK or OTEL collector instance, see the following:

### [Using the OTEL Collector](https://docs.sentry.io/concepts/otlp.md#using-the-otel-collector)

You can configure your OTEL collector instance to send traces to Sentry directly. This requires you to add an `otlphttp` exporter to your collector instance. Sentry's OTLP endpoints are project-specific, so you might also need to add a [routing connector](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector) to route traces to the correct project.

`otel-collector.yaml`

```yaml
exporters:
  otlphttp:
    traces_endpoint: ___OTLP_TRACES_URL___
    headers:
      x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___"
    compression: gzip
    encoding: proto
    timeout: 30s
```

### [Using an OpenTelemetry SDK](https://docs.sentry.io/concepts/otlp.md#using-an-opentelemetry-sdk)

You can configure the OpenTelemetry Exporter directly in your application code. Here is an example with the OpenTelemetry Node SDK:

`app.ts`

```typescript
import { NodeSDK } from "@opentelemetry/sdk-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";

const sdk = new NodeSDK({
  traceExporter: new OTLPTraceExporter({
    url: "___OTLP_TRACES_URL___",
    headers: {
      "x-sentry-auth": "sentry sentry_key=___PUBLIC_KEY___",
    },
  }),
});

sdk.start();
```

## [OpenTelemetry Logs](https://docs.sentry.io/concepts/otlp.md#opentelemetry-logs)

This feature is currently in open beta. Please reach out to <feedback-logging@sentry.io> if you have feedback or questions. Features in beta are still in-progress and may have bugs. We recognize the irony.

If you have an existing OpenTelemetry log instrumentation, you can configure your OpenTelemetry exporter to send logs to Sentry directly. Sentry's OTLP ingestion logs endpoint has the following known limitations:

* Array attributes are partially supported. We ingest and display array attributes, but they cannot be searched, filtered, or aggregated.

You can find the values of Sentry's OTLP logs endpoint and public key in your Sentry project settings.

1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry.
2. Select a project from the list.
3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading.

The easiest way to configure an OpenTelemetry exporter is with environment variables. You'll need to configure the logs endpoint URL, as well as the authentication headers. Set these variables on the server where your application is running.

`.env`

```bash
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="___OTLP_LOGS_URL___"
export OTEL_EXPORTER_OTLP_LOGS_HEADERS="x-sentry-auth=sentry sentry_key=___PUBLIC_KEY___"
```

If you prefer to explicitly configure an OpenTelemetry SDK or OTEL collector instance, see the following:

### [Using the OTEL Collector](https://docs.sentry.io/concepts/otlp.md#using-the-otel-collector-1)

You can configure your OTEL collector instance to send logs to Sentry directly. This requires you to add an `otlphttp` exporter to your collector instance. Sentry's OTLP endpoints are project-specific, so you might also need to add a [routing connector](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector) to route logs to the correct project.

`otel-collector.yaml`

```yaml
exporters:
  otlphttp:
    logs_endpoint: ___OTLP_LOGS_URL___
    headers:
      x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___"
    compression: gzip
    encoding: proto
    timeout: 30s
```

### [Using an OpenTelemetry SDK](https://docs.sentry.io/concepts/otlp.md#using-an-opentelemetry-sdk-1)

Alternatively, you can configure the OpenTelemetry Exporter directly in your application code. Here is an example with the OpenTelemetry Node SDK:

`app.ts`

```typescript
import {
  LoggerProvider,
  BatchLogRecordProcessor,
} from "@opentelemetry/sdk-logs";
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";

const logExporter = new OTLPLogExporter({
  url: "___OTLP_LOGS_URL___",
  headers: {
    "x-sentry-auth": "sentry sentry_key=___PUBLIC_KEY___",
  },
});
const loggerProvider = new LoggerProvider({
  processors: [new BatchLogRecordProcessor(logExporter)],
});

const logger = loggerProvider.getLogger("default", "1.0.0");
```

## [Distributed Tracing between Sentry Instrumentation and OpenTelemetry Instrumentation](https://docs.sentry.io/concepts/otlp.md#distributed-tracing-between-sentry-instrumentation-and-opentelemetry-instrumentation)

If you have a frontend or services instrumented with the Sentry SDK, and you are also instrumenting with OpenTelemetry, you can use the `propagateTraceparent` exposed in the Sentry SDK to propagate the W3C Trace Context `traceparent` header to the OpenTelemetry instrumentation. This will allow you to continue traces from Sentry instrumented services.

The following SDKs support the `propagateTraceparent` option:

### [JavaScript](https://docs.sentry.io/concepts/otlp.md#javascript)

* [![javascript.browser icon](https://docs.sentry.io/_next/static/media/javascript.d53aab1f.svg)Browser JavaScript](https://docs.sentry.io/platforms/javascript/configuration/options.md#propagateTraceparent)
* [![javascript.angular icon](https://docs.sentry.io/_next/static/media/angularjs.8e98e235.svg)Angular](https://docs.sentry.io/platforms/javascript/guides/angular/configuration/options.md#propagateTraceparent)
* [![javascript.astro icon](https://docs.sentry.io/_next/static/media/astro.3cb960c2.svg)Astro](https://docs.sentry.io/platforms/javascript/guides/astro/configuration/options.md#propagateTraceparent)
* [![javascript.ember icon](https://docs.sentry.io/_next/static/media/ember.9862ba42.svg)Ember](https://docs.sentry.io/platforms/javascript/guides/ember/configuration/options.md#propagateTraceparent)
* [![javascript.gatsby icon](https://docs.sentry.io/_next/static/media/gatsby.d1e74154.svg)Gatsby](https://docs.sentry.io/platforms/javascript/guides/gatsby/configuration/options.md#propagateTraceparent)
* [![javascript.nextjs icon](https://docs.sentry.io/_next/static/media/nextjs.27669790.svg)Next.js](https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options.md#propagateTraceparent)
* [![javascript.nuxt icon](https://docs.sentry.io/_next/static/media/nuxt.90663273.svg)Nuxt](https://docs.sentry.io/platforms/javascript/guides/nuxt/configuration/options.md#propagateTraceparent)
* [![javascript.react icon](https://docs.sentry.io/_next/static/media/react.e3c301d5.svg)React](https://docs.sentry.io/platforms/javascript/guides/react/configuration/options.md#propagateTraceparent)
* [![javascript.react-router icon](https://docs.sentry.io/_next/static/media/react-router.e30ce352.svg)React Router](https://docs.sentry.io/platforms/javascript/guides/react-router/configuration/options.md#propagateTraceparent)
* [![javascript.remix icon](https://docs.sentry.io/_next/static/media/remix.27fc09d0.svg)Remix](https://docs.sentry.io/platforms/javascript/guides/remix/configuration/options.md#propagateTraceparent)
* [![javascript.solid icon](https://docs.sentry.io/_next/static/media/solid.398fcbf4.svg)Solid](https://docs.sentry.io/platforms/javascript/guides/solid/configuration/options.md#propagateTraceparent)
* [![javascript.solidstart icon](https://docs.sentry.io/_next/static/media/solidstart.a4c37fbe.svg)SolidStart](https://docs.sentry.io/platforms/javascript/guides/solidstart/configuration/options.md#propagateTraceparent)
* [![javascript.svelte icon](https://docs.sentry.io/_next/static/media/svelte.d8e9a29b.svg)Svelte](https://docs.sentry.io/platforms/javascript/guides/svelte/configuration/options.md#propagateTraceparent)
* [![javascript.sveltekit icon](https://docs.sentry.io/_next/static/media/svelte.d8e9a29b.svg)SvelteKit](https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options.md#propagateTraceparent)
* [![javascript.vue icon](https://docs.sentry.io/_next/static/media/vue.2bb828dc.svg)Vue](https://docs.sentry.io/platforms/javascript/guides/vue/configuration/options.md#propagateTraceparent)
* [![javascript.wasm icon](https://docs.sentry.io/_next/static/media/wasm.1533893e.svg)Wasm](https://docs.sentry.io/platforms/javascript/guides/wasm/configuration/options.md#propagateTraceparent)

### [Mobile](https://docs.sentry.io/concepts/otlp.md#mobile)

* [![android icon](https://docs.sentry.io/_next/static/media/android.b3576036.svg)Android](https://docs.sentry.io/platforms/android/configuration/options.md#propagateTraceparent)
* [![dart.flutter icon](https://docs.sentry.io/_next/static/media/flutter.b7cd4dd4.svg)Flutter](https://docs.sentry.io/platforms/dart/guides/flutter/configuration/options.md#propagateTraceparent)
* [![native icon](https://docs.sentry.io/_next/static/media/nativec.2ce68873.svg)Native](https://docs.sentry.io/platforms/native/configuration/options.md#propagate_traceparent)
* [![react-native icon](https://docs.sentry.io/_next/static/media/react-native.a5e5ad76.svg)React Native](https://docs.sentry.io/platforms/react-native/configuration/options.md#propagateTraceparent)

## [Dedicated Integrations](https://docs.sentry.io/concepts/otlp.md#dedicated-integrations)

The following SDKs have dedicated integrations that make OTLP setup easy:

* [![python icon](https://docs.sentry.io/_next/static/media/python.94740f0e.svg)Python](https://docs.sentry.io/platforms/python/integrations/otlp.md)

## [OpenTelemetry Collector Guides](https://docs.sentry.io/concepts/otlp.md#opentelemetry-collector-guides)

View the [OpenTelemetry Collector Guides](https://docs.sentry.io/product/drains/integration/opentelemetry-collector.md#open-telemetry-collector-guides) to learn how to leverage the OpenTelemetry Collector to send traces and logs to Sentry from different sources like Kafka or Nginx.
