---
title: "OpenTelemetry (OTLP)"
description: "Learn about using OTLP to automatically send OpenTelemetry Traces to Sentry."
url: https://docs.sentry.io/platforms/php/integrations/otlp/
---

# OpenTelemetry (OTLP) | Sentry for PHP

The OTLP integration configures the Sentry SDK to automatically send trace data instrumented by an OpenTelemetry SDK to Sentry's [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otel/protocol/) [ingestion endpoint](https://docs.sentry.io/concepts/otlp.md).

##### Mutually Exclusive With Sentry Tracing

Using Sentry tracing and OTLP tracing at the same time is not supported. If Sentry tracing is enabled (`traces_sample_rate`, `traces_sampler`, or `enable_tracing`), the integration will not be registered.

## [Install](https://docs.sentry.io/platforms/php/integrations/otlp.md#install)

Install the required OpenTelemetry packages via Composer:

```bash
composer require \
  open-telemetry/sdk \
  open-telemetry/exporter-otlp
```

## [Configure](https://docs.sentry.io/platforms/php/integrations/otlp.md#configure)

You need to configure both the OpenTelemetry and Sentry SDKs to get trace data.

### [OpenTelemetry](https://docs.sentry.io/platforms/php/integrations/otlp.md#opentelemetry)

For the OpenTelemetry SDK, you need to [configure instrumentation](https://opentelemetry.io/docs/languages/php/instrumentation/) you want to capture.

### [Sentry](https://docs.sentry.io/platforms/php/integrations/otlp.md#sentry)

For the Sentry SDK, add the `OTLPIntegration` to your existing configuration.

```php
\Sentry\init([
    'dsn' => 'https://<key>@o<orgId>.ingest.sentry.io/<projectId>',
    // Add data like request headers and IP for users, if applicable;
    // see https://docs.sentry.io/platforms/php/data-management/data-collected/ for more info
    'send_default_pii' => true,
    'integrations' => [
        new \Sentry\Integration\OTLPIntegration(),
    ],
]);
```

## [Behavior](https://docs.sentry.io/platforms/php/integrations/otlp.md#behavior)

Under the hood, the `OTLPIntegration` sets up the following parts:

* A [`SpanExporter`](https://opentelemetry.io/docs/concepts/components/#exporters) that automatically configures the OTLP ingestion endpoint from your Sentry DSN. This enables tracing in Sentry. **Note:** *Do not* also set up tracing via the PHP SDK (i.e. do not set `traces_sample_rate`, `traces_sampler`, or `enable_tracing`).
* Trace/Span linking for all other Sentry events such as Errors, Logs, and Metrics

Cross-service trace propagation uses OTel's default W3C `traceparent` headers and does not require additional configuration. See [Exporters, Event Linking, and Propagation](https://docs.sentry.io/concepts/otlp/sentry-with-otel.md#exporters-event-linking-and-propagation) for details.

## [Options](https://docs.sentry.io/platforms/php/integrations/otlp.md#options)

You can pass the following arguments to the `OTLPIntegration` constructor:

* `setupOtlpTracesExporter` (bool):

  Automatically configure an Exporter to send OTLP traces to the right project from the DSN or `collectorUrl`, defaults to `true`.

  Set to `false` to set up the TracerProvider manually.

* `collectorUrl` (string|null):

  URL of your own OpenTelemetry collector. When set, the exporter will send traces to this URL instead of the Sentry OTLP endpoint derived from the DSN.

## [Supported Versions](https://docs.sentry.io/platforms/php/integrations/otlp.md#supported-versions)

* PHP: 8.1+ (required by the OpenTelemetry SDK)
* sentry/sentry: 4.23.0+
