---
title: "OpenTelemetry Collector"
description: "Learn how to set up the OpenTelemetry Collector to forward logs and traces data to Sentry."
url: https://docs.sentry.io/concepts/otlp/forwarding/pipelines/collector/
---

# OpenTelemetry Collector Setup

The [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/) is a vendor-agnostic proxy that can receive, process, and export telemetry data. You can configure the Collector to forward logs and traces to Sentry using the `otlphttp` exporter.

If you're looking to forward logs and traces from an OpenTelemetry SDK directly to Sentry, take a look at our [OpenTelemetry (OTLP) documentation](https://docs.sentry.io/concepts/otlp.md) instead.

## [Prerequisites](https://docs.sentry.io/concepts/otlp/forwarding/pipelines/collector.md#prerequisites)

Before you begin, ensure you have:

* OpenTelemetry Collector installed and running
* A Sentry project you want to send data to

## [Step 1: Get Your Sentry OTLP Credentials](https://docs.sentry.io/concepts/otlp/forwarding/pipelines/collector.md#step-1-get-your-sentry-otlp-credentials)

Find these in [Sentry Project Settings](https://sentry.io/settings/projects/) under **Client Keys (DSN)** > **OpenTelemetry (OTLP)**.

* Use the **combined endpoint** if sending both logs and traces
* The Collector appends `/v1/logs` or `/v1/traces` automatically

```bash
# Logs endpoint
___OTLP_LOGS_URL___

# Traces endpoint
___OTLP_TRACES_URL___

# Combined endpoint (logs + traces)
___OTLP_URL___

# Auth header (include in all requests)
x-sentry-auth: sentry sentry_key=___PUBLIC_KEY___
```

## [Step 2: Configure the Collector](https://docs.sentry.io/concepts/otlp/forwarding/pipelines/collector.md#step-2-configure-the-collector)

Update your OpenTelemetry Collector configuration to add the `otlphttp` exporter pointing to Sentry.

### [Logs Only](https://docs.sentry.io/concepts/otlp/forwarding/pipelines/collector.md#logs-only)

Use `logs_endpoint` to forward only logs to Sentry.

`otel-collector.yaml`

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

### [Traces Only](https://docs.sentry.io/concepts/otlp/forwarding/pipelines/collector.md#traces-only)

Use `traces_endpoint` to forward only traces to Sentry.

`otel-collector.yaml`

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

### [Logs and Traces](https://docs.sentry.io/concepts/otlp/forwarding/pipelines/collector.md#logs-and-traces)

Use the combined `endpoint` to forward both logs and traces. The Collector appends the appropriate path for each signal type.

`otel-collector.yaml`

```yaml
exporters:
  otlphttp/sentry:
    endpoint: ___OTLP_URL___
    headers:
      x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___"
    compression: gzip
    encoding: proto
```

## [Routing to Multiple Projects](https://docs.sentry.io/concepts/otlp/forwarding/pipelines/collector.md#routing-to-multiple-projects)

For simpler multi-project routing, consider the [Sentry Exporter](https://docs.sentry.io/concepts/otlp/forwarding/pipelines/sentry-exporter.md) which routes telemetry based on `service.name` without a routing connector, and can automatically create new Sentry projects on-demand.

Sentry's OTLP endpoints are project-specific. To route telemetry from different services to different Sentry projects using `otlphttp`, use the [routing connector](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector).

This example routes logs to different Sentry projects based on the `service.name` attribute:

* Logs with `service.name: "service-b"` go to Project B
* All other logs go to Project A (the default)

`otel-collector.yaml`

```yaml
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317

connectors:
  routing:
    default_pipelines: [logs/project-a]
    error_mode: ignore
    table:
      - statement: route() where attributes["service.name"] == "service-b"
        pipelines: [logs/project-b]

exporters:
  otlphttp/project-a:
    logs_endpoint: https://o00000.ingest.sentry.io/api/1111111/integration/otlp/v1/logs
    headers:
      x-sentry-auth: "sentry sentry_key=example-public-key-for-project-a"
    compression: gzip
    encoding: proto

  otlphttp/project-b:
    logs_endpoint: https://o00000.ingest.sentry.io/api/2222222/integration/otlp/v1/logs
    headers:
      x-sentry-auth: "sentry sentry_key=example-public-key-for-project-b"
    compression: gzip
    encoding: proto

service:
  pipelines:
    logs:
      receivers: [otlp]
      exporters: [routing]
    logs/project-a:
      receivers: [routing]
      exporters: [otlphttp/project-a]
    logs/project-b:
      receivers: [routing]
      exporters: [otlphttp/project-b]
```
