feat(telemetry): add custom headers for OTLP exports (metrics, tracing, access logs)#7674
Conversation
63fd03f to
04c7b52
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7674 +/- ##
==========================================
+ Coverage 72.77% 72.81% +0.03%
==========================================
Files 235 236 +1
Lines 35165 35190 +25
==========================================
+ Hits 25592 25623 +31
+ Misses 7756 7750 -6
Partials 1817 1817 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c58e24a to
5f69a4f
Compare
2483048 to
36f5bee
Compare
|
ok made a revision also to PR desc to hopefully answer questions in comments. I will revisit this again monday if there is more feedback. |
36f5bee to
1a16872
Compare
|
pulling into draft while I remove the port dodging things for things we can't control yet. |
1a16872 to
47998d6
Compare
|
also I just realized we never added this for tracing either, so will add that to the PR |
a5b5a19 to
c7e3ecf
Compare
| spec: | ||
| telemetry: | ||
| metrics: | ||
| # TODO: Some backends like otel-tui and Elastic require delta temporality |
There was a problem hiding this comment.
These problems are too much to do in this PR, and I can over time try to clean these up also
607296e to
5bff38d
Compare
| log := collector.TakeLog() | ||
| require.NotNil(t, log) | ||
| require.Contains(t, log.Body.GetStringValue(), `HTTP/1.1" 200`) | ||
| require.Equal(t, "Bearer test-api-key", testotel.GetAttributeString(log.Attributes, "grpc.metadata.authorization")) |
There was a problem hiding this comment.
@mathetake @anuraaga you might like this sneaky trick to verify the headers/metadata received by otel. propagate them into fake span attrs
412773b to
ea11614
Compare
|
ok I updated this as I noticed the same thing was missing everywhere, in logs metrics and tracing. fixed so that the tests are coherent and we don't need to go back and clean this up multiple times. There's been a history of fragmentation and not following up later, so doing otel holistically for one thing is a good thing. |
|
if this lasts until 2026 I will close it as unplanned/unwanted. I won't be attending to perpetual rebasing. I want to make things better, but this has been a low-light. Not only were things left half-finished, but finishing them has been beyond arduous |
207b78d to
f99c543
Compare
|
re ran soup to nuts and the example works fine |
|
/retest |
|
does anyone have access to merge this considering there are 2 approvals? |
c9c13b9 to
b46e22a
Compare
Adds a Headers field to the OpenTelemetry configuration for access logging, tracing, and metrics. This allows configuring gRPC initial metadata (e.g., Authorization headers) for authenticated OTLP export to collectors like Elastic, Datadog, or cloud providers. Also adds MinItems=1 validation for OTLP headers. Signed-off-by: Adrian Cole <adrian@tetrate.io>
…consistency Signed-off-by: Adrian Cole <adrian@tetrate.io>
b46e22a to
c3d6f0a
Compare
…g, access logs) (envoyproxy#7674) * feat(telemetry): add headers support for OpenTelemetry gRPC signals Adds a Headers field to the OpenTelemetry configuration for access logging, tracing, and metrics. This allows configuring gRPC initial metadata (e.g., Authorization headers) for authenticated OTLP export to collectors like Elastic, Datadog, or cloud providers. Also adds MinItems=1 validation for OTLP headers. Signed-off-by: Adrian Cole <adrian@tetrate.io> * feat(telemetry): nest tracing headers in openTelemetry field for API consistency Signed-off-by: Adrian Cole <adrian@tetrate.io> --------- Signed-off-by: Adrian Cole <adrian@tetrate.io> Signed-off-by: Matt Miller <millermatt@outlook.com>
**Description** Switches OTLP default transport from HTTP to gRPC in test fixtures and examples. This prepares for Envoy Gateway integration which currently only supports OTLP/gRPC for access logs. Once Envoy Gateway exposes OTLP/HTTP (pending upstream changes in Envoy), we can switch back. **Related Issues/PRs (if applicable)** - envoyproxy/envoy#42445 (OTLP/HTTP access logs in Envoy) - envoyproxy/gateway#7674 (OTLP headers support) Signed-off-by: Adrian Cole <adrian@tetrate.io>
What type of PR is this?
feat(telemetry): add new feature
What this PR does / why we need it:
Adds support for custom headers on all OTLP/gRPC exports (metrics, tracing, and access logs), enabling authentication with collectors like Elastic Cloud, Datadog, or cloud providers that require API keys or bearer tokens.
This uses Envoy's
GrpcService.initial_metadatato send headers as gRPC metadata.Release Notes: Yes
Notes:
This PR includes an example showing authenticated OTLP exports for all three signals. The example uses otel-tui, but could use anything else.
Changes
Headersfield toProxyOpenTelemetrySinkintelemetry.metrics.sinks[].openTelemetryHeadersfield toTracingProviderintelemetry.tracing.providerHeadersfield toOpenTelemetryAccessLogintelemetry.accessLog.settings[].sinks[].openTelemetryAll three use the same pattern: a list of
HTTPHeaderobjects withnameandvaluefields.FAQ
Why not use SecretObjectReference for sensitive headers?
For EnvoyProxy config that supports file-based standalone mode, Kubernetes secrets are not available. Plain text headers are needed regardless.
For example, Honeycomb requires non-secret headers like
x-honeycomb-dataset. Secret support can be added in a follow-up for Kubernetes mode.