OpenTelemetry Collector Setup

Learn how to set up the OpenTelemetry Collector to forward logs and traces data to Sentry.

The OpenTelemetry 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 instead.

Before you begin, ensure you have:

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

Find these in Sentry Project Settings 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
Copied
# 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___

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

Use logs_endpoint to forward only logs to Sentry.

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

Use traces_endpoint to forward only traces to Sentry.

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

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

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

Sentry's OTLP endpoints are project-specific. To route telemetry from different services to different Sentry projects using otlphttp, use the routing connector.

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
Copied
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]
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").