Skip to content

feat(otel): support OTEL_EXPORTER_OTLP_HEADERS for authenticated export - #76

Merged
prashar32 merged 1 commit into
mainfrom
feat/otel-export-headers
Jun 6, 2026
Merged

feat(otel): support OTEL_EXPORTER_OTLP_HEADERS for authenticated export#76
prashar32 merged 1 commit into
mainfrom
feat/otel-export-headers

Conversation

@prashar32

Copy link
Copy Markdown
Owner

Authenticated OTLP export

The OTel exporter could only talk to an unauthenticated endpoint — there was no way to send an auth token. So any backend that requires one couldn't receive spans, and the example's Honeycomb row (x-honeycomb-team header "via std OTEL env") was actually a broken promise.

This reads the standard OTEL_EXPORTER_OTLP_HEADERS (and the traces-specific OTEL_EXPORTER_OTLP_TRACES_HEADERS, which wins if both are set) — a comma-separated list of key=value pairs — and attaches them to every span export over both gRPC and HTTP:

export OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io
export OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=$HONEYCOMB_API_KEY"
# or any Bearer endpoint:
export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer $TOKEN"

Header values carry secrets, so they're never logged (the startup line logs only endpoint + protocol).

Verified

  • Parse: whitespace trimming, values containing =, malformed pairs skipped, TRACES_HEADERS precedence over HEADERS.
  • On the wire: a test stands up an OTLP/HTTP receiver, exports a span through the real exporter, and asserts the Authorization header arrives. go test ./... green.

Unblocks authenticated backends like Honeycomb and Grafana Cloud.

The exporter could only reach an unauthenticated OTLP endpoint — there was no
way to send an auth token, so a backend that requires one (Honeycomb's
x-honeycomb-team, a Bearer token, Grafana Cloud) couldn't receive spans. The
OTel example even documented Honeycomb "via the std OTEL env header," which
didn't actually work.

Read the standard OTEL_EXPORTER_OTLP_HEADERS (and the traces-specific
OTEL_EXPORTER_OTLP_TRACES_HEADERS, which takes precedence) as a comma-separated
key=value list and attach them to every export over grpc and http. Values carry
secrets, so they're never logged.

Tested the parse (whitespace, value-with-=, malformed pairs, precedence) and
asserted the header actually reaches the endpoint on the wire.
@prashar32
prashar32 force-pushed the feat/otel-export-headers branch from b95f068 to 2de29be Compare June 6, 2026 19:45
@prashar32
prashar32 merged commit 101efe9 into main Jun 6, 2026
5 checks passed
@prashar32 prashar32 mentioned this pull request Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant