OpenTelemetry Protocol (OTLP)

Learn how to send OpenTelemetry trace data directly to Sentry from OpenTelemetry SDKs.

Sentry can ingest OpenTelemetry traces and logs directly via the OpenTelemetry Protocol. Sentry does not support ingesting OTLP metrics.

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 are shown in the Trace View.
  • 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.

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
Copied
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://o0.ingest.sentry.io/api/0/otlp/v1/traces/"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-sentry-auth=sentry sentry_key=examplePublicKey"

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

app.ts
Copied
import { NodeSDK } from "@opentelemetry/sdk-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";

const sdk = new NodeSDK({
  traceExporter: new OTLPTraceExporter({
    url: "https://o0.ingest.sentry.io/api/0/otlp/v1/traces/",
    headers: {
      "x-sentry-auth": "sentry sentry_key=examplePublicKey",
    },
  }),
});

sdk.start();

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 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.

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.

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
Copied
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="https://o0.ingest.sentry.io/api/0/otlp/v1/logs/"
export OTEL_EXPORTER_OTLP_LOGS_HEADERS="x-sentry-auth=sentry sentry_key=examplePublicKey"

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

app.ts
Copied
import {
  LoggerProvider,
  BatchLogRecordProcessor,
} from "@opentelemetry/sdk-logs";
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";

const logExporter = new OTLPLogExporter({
  url: "https://o0.ingest.sentry.io/api/0/otlp/v1/logs/",
  headers: {
    "x-sentry-auth": "sentry sentry_key=examplePublicKey",
  },
});
const loggerProvider = new LoggerProvider({
  processors: [new BatchRecordProcessor(logExporter)],
});

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

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 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.

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:

Was this helpful?
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").