self-hosted icon indicating copy to clipboard operation
self-hosted copied to clipboard

Add Native OTLP Ingestion

Open aldy505 opened this issue 5 months ago • 3 comments

Problem Statement

Announcement: https://github.com/getsentry/sentry/discussions/85902#discussioncomment-14568258 Product docs: https://docs.sentry.io/concepts/otlp/

Solution Brainstorm

The way we'll tell you how to configure this should be versioned (learned this the hard way from User Feedback feature). Grab the version you're currently on (or if yours is higher than any of these, choose the highest one).

aldy505 avatar Jul 25 '25 01:07 aldy505

Setup Guide for 25.8.0

You will need to have Performance Trace Explorer & Event Analytics Platform enabled. See #3592 on how to enable that.

Modify sentry.conf.py:

SENTRY_FEATURES = # ...
  ) +
  # Native OpenTelemetry Ingestion
  (
      "organizations:standalone-span-ingestion",
      "performance-otel-friendly-ui",
      "projects:span-metrics-extraction",
      "projects:relay-otel-endpoint", # Required
  )

Re-run ./install.sh since the changes should be on containers that uses the sentry image and relay.

How to use this

  1. Create a Sentry project from the web UI
  2. Copy the generated DSN, it have the format of:
    https://{{ DSN_KEY }}@sentry.example.com/{{ PROJECT_ID }}
    
  3. Setup OpenTelemetry tracing on your application. Usually, you can configure it with environment variables, you need to set these 2:
    OTEL_EXPORTER_OTLP_ENDPOINT=https://sentry.example.com
    OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://sentry.example.com/api/{{ PROJECT_ID }}/otlp/v1/traces
    OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-sentry-auth=sentry sentry_key={{ DSN_KEY }}"
    
    Example in Go:
    func newTracerProvider() (*trace.TracerProvider, error) {
        traceExporter, err := otlptracehttp.New(
                context.TODO(),
                otlptracehttp.WithEndpointURL("https://sentry.example.com/api/{{ PROJECT_ID }}/otlp/v1/traces"),
                otlptracehttp.WithHeaders(map[string]string{"x-sentry-auth": "sentry sentry_key={{ DSN_KEY }}"})
        )
        if err != nil {
            return nil, err
        }
    
        tracerProvider := trace.NewTracerProvider(
            trace.WithBatcher(traceExporter,
                trace.WithBatchTimeout(time.Second)),
        )
        return tracerProvider, nil
    }
    
    Example in Node.js:
    import { NodeSDK } from "@opentelemetry/sdk-node";
    import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
    const sdk = new NodeSDK({
      traceExporter: new OTLPTraceExporter({
        url: "https://sentry.example.com/api/{{ PROJECT_ID }}/otlp/v1/traces",
        headers: {
          "x-sentry-auth": "sentry sentry_key={{ DSN_KEY }}",
        },
      }),
    });
    sdk.start();
    

If you are using a reverse proxy, make sure that this endpoint is on the allowlist.

aldy505 avatar Jul 25 '25 01:07 aldy505

Setup Guide for 25.10.0

Skipped 25.9.0 because people break things often. Make sure to have Performance Trace Explorer + Event Analytics Platform enabled.

Modify sentry.conf.py:

SENTRY_FEATURES = # ...
  ) +
  # Native OpenTelemetry Ingestion
  (
    "organizations:performance-otel-friendly-ui",
    "organizations:relay-otlp-traces-endpoint", 
    "organizations:relay-otel-logs-endpoint",
  )

Re-run ./install.sh since the changes should be on containers that uses the sentry image and relay.

How to use this

Usage docs: https://docs.sentry.io/concepts/otlp/

If you're behind a reverse proxy to gate this endpoint, make sure to allow:

  • https://sentry.example.com/api/{\d+}/integration/otlp/v1/traces
  • https://sentry.example.com/api/{\d+}/integration/otlp/v1/logs

aldy505 avatar Oct 10 '25 08:10 aldy505