# OTLP 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're using OTel without a Sentry SDK, you can send traces directly to Sentry's OTLP endpoint. You can find your endpoint URL and auth key in [Project settings > Client Keys (DSN)](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/).

## [Configuration](https://docs.sentry.io/concepts/otlp/otlp-traces.md#configuration)

`.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___"
```

## [Using the OTel Collector](https://docs.sentry.io/concepts/otlp/otlp-traces.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
```

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

If you want to reduce the volume of traces sent to Sentry, you can use the OTel Collector's [probabilistic sampler processor](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/probabilisticsamplerprocessor) to sample a percentage of your traffic.

`otel-collector.yaml`

```yaml
processors:
  probabilistic_sampler:
    sampling_percentage: 10 # Send 10% of traces to Sentry

exporters:
  otlphttp/sentry:
    traces_endpoint: ___OTLP_TRACES_URL___
    headers:
      x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___"
    compression: gzip
    encoding: proto

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [probabilistic_sampler]
      exporters: [otlphttp/sentry]
```

The probabilistic sampler uses consistent hashing on the trace ID, so all spans from the same trace are either sampled or dropped together.

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

You can configure the OTel Exporter directly in your application code. Here is an example with the OTel 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();
```

## [Known Limitations](https://docs.sentry.io/concepts/otlp/otlp-traces.md#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).
