Skip to content

Conversation

@codefromthecrypt
Copy link
Contributor

@codefromthecrypt codefromthecrypt commented Dec 5, 2025

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_metadata to 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.

Screenshot 2025-12-11 at 9 49 34 AM Screenshot 2025-12-11 at 9 49 13 AM

Changes

  • Metrics: Added Headers field to ProxyOpenTelemetrySink in telemetry.metrics.sinks[].openTelemetry
  • Tracing: Added Headers field to TracingProvider in telemetry.tracing.provider
  • Access Logs: Added Headers field to OpenTelemetryAccessLog in telemetry.accessLog.settings[].sinks[].openTelemetry

All three use the same pattern: a list of HTTPHeader objects with name and value fields.

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.

@codefromthecrypt codefromthecrypt requested a review from a team as a code owner December 5, 2025 06:44
@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.81%. Comparing base (dd2861f) to head (c3d6f0a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/gatewayapi/listener.go 66.66% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codefromthecrypt codefromthecrypt force-pushed the otel-grpc-headers branch 2 times, most recently from c58e24a to 5f69a4f Compare December 5, 2025 07:42
@codefromthecrypt codefromthecrypt force-pushed the otel-grpc-headers branch 2 times, most recently from 2483048 to 36f5bee Compare December 5, 2025 12:13
@codefromthecrypt
Copy link
Contributor Author

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.

@codefromthecrypt codefromthecrypt marked this pull request as draft December 7, 2025 00:29
@codefromthecrypt
Copy link
Contributor Author

pulling into draft while I remove the port dodging things for things we can't control yet.

@codefromthecrypt
Copy link
Contributor Author

also I just realized we never added this for tracing either, so will add that to the PR

@codefromthecrypt codefromthecrypt changed the title feat(accesslog): add custom headers for OTLP access log exports feat(telemetry): add custom headers for OTLP exports (metrics, tracing, access logs) Dec 7, 2025
spec:
telemetry:
metrics:
# TODO: Some backends like otel-tui and Elastic require delta temporality
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These problems are too much to do in this PR, and I can over time try to clean these up also

@codefromthecrypt codefromthecrypt force-pushed the otel-grpc-headers branch 3 times, most recently from 607296e to 5bff38d Compare December 7, 2025 05:42
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"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mathetake @anuraaga you might like this sneaky trick to verify the headers/metadata received by otel. propagate them into fake span attrs

@codefromthecrypt codefromthecrypt force-pushed the otel-grpc-headers branch 2 times, most recently from 412773b to ea11614 Compare December 7, 2025 06:20
@codefromthecrypt codefromthecrypt marked this pull request as ready for review December 7, 2025 06:20
@codefromthecrypt
Copy link
Contributor Author

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.

@codefromthecrypt
Copy link
Contributor Author

this is pending merge of #7720 which has been stalled several days without any known reason. If anyone wants this stuff to land, please encourage maintainers to click merge and I'll rebase this after

@codefromthecrypt
Copy link
Contributor Author

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

@codefromthecrypt codefromthecrypt marked this pull request as ready for review December 29, 2025 01:28
@codefromthecrypt
Copy link
Contributor Author

re ran soup to nuts and the example works fine

zirain
zirain previously approved these changes Dec 29, 2025
jukie
jukie previously approved these changes Dec 29, 2025
@jukie jukie requested review from a team, arkodg and zirain December 29, 2025 18:31
@zirain
Copy link
Member

zirain commented Dec 30, 2025

/retest

zirain
zirain previously approved these changes Dec 30, 2025
@codefromthecrypt
Copy link
Contributor Author

does anyone have access to merge this considering there are 2 approvals?

Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

@arkodg arkodg requested review from jukie and zirain January 2, 2026 04:13
@arkodg arkodg added this to the v1.7.0-rc.1 Release milestone Jan 2, 2026
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 <[email protected]>
@zirain zirain merged commit e2a495d into envoyproxy:main Jan 3, 2026
35 checks passed
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.

4 participants