|
| 1 | +--- |
| 2 | +title: OTLP |
| 3 | +sidebar_order: 400 |
| 4 | +description: "Learn how to send OpenTelemetry trace data directly to Sentry from OpenTelemetry SDKs." |
| 5 | +keywords: ["otlp", "otel", "opentelemetry"] |
| 6 | +--- |
| 7 | + |
| 8 | +<Include name="feature-available-for-user-group-limited-avail.mdx" /> |
| 9 | + |
| 10 | +Sentry can ingest [OpenTelemetry](https://opentelemetry.io) traces directly via the [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otel/protocol/). If you have existing OpenTelemetry trace instrumentation, you can configure your OpenTelemetry exporter to send traces to Sentry directly. |
| 11 | + |
| 12 | +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. |
| 13 | + |
| 14 | +```bash {filename: .env} |
| 15 | +export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="___OTLP_TRACES_URL___"" |
| 16 | +export OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-sentry-auth=sentry sentry_key=___PUBLIC_KEY___" |
| 17 | +``` |
| 18 | +
|
| 19 | +If you don't want to use environment variables, you can configure the OpenTelemetry Exporter directly in your application code. |
| 20 | +
|
| 21 | +```typescript {filename: app.ts} |
| 22 | +import { NodeSDK } from "@opentelemetry/sdk-node"; |
| 23 | +import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; |
| 24 | +
|
| 25 | +const sdk = new NodeSDK({ |
| 26 | + traceExporter: new OTLPTraceExporter({ |
| 27 | + url: "___OTLP_TRACES_URL___", |
| 28 | + headers: { |
| 29 | + "x-sentry-auth": "sentry sentry_key=___PUBLIC_KEY___", |
| 30 | + }, |
| 31 | + }), |
| 32 | +}); |
| 33 | +
|
| 34 | +sdk.start(); |
| 35 | +``` |
| 36 | +
|
| 37 | +You can find the values of Sentry's OTLP endpoint and public key in your Sentry project settings. |
| 38 | +
|
| 39 | +1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry. |
| 40 | +2. Select a project from the list. |
| 41 | +3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading. |
0 commit comments