Skip to content

added support for otlp headers #3201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seun-ja
Copy link
Contributor

@seun-ja seun-ja commented Jul 17, 2025

Fixes #2811

Signed-off-by: Aminu 'Seun Joshua <[email protected]>
@lann
Copy link
Collaborator

lann commented Jul 17, 2025

Did anyone try this without any code changes? I think the opentelemetry crate already checks some of the standard env vars...

@lann
Copy link
Collaborator

lann commented Jul 17, 2025

@seun-ja
Copy link
Contributor Author

seun-ja commented Jul 17, 2025

Yeah, looks like they all are checked. Judging by the code base.

@seun-ja
Copy link
Contributor Author

seun-ja commented Jul 17, 2025

@lann would you suggest #2811 be closed?

Comment on lines +7 to +14
use crate::env::OtelExporterOtlpHeaders;

/// Injects the current W3C TraceContext into the provided request.
pub fn inject_trace_context<'a>(req: impl Into<HeaderInjector<'a>>) {
let mut injector = req.into();
for (key, value) in OtelExporterOtlpHeaders::headers() {
injector.set(&key, value);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We wouldn't want to inject the headers here. This is for propagating context to outgoing requests. OTEL_EXPORTER_OTLP_TRACES_HEADERS is for setting headers on requests made to the OTel collector to export traces.

@calebschoepp
Copy link
Collaborator

@seun-ja the next step here would be to run Spin off main and see if it respects these env vars already. You could point Spin at a collector that is actually just a proxy to see if the headers are being set or not.

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.

Support for OTEL_EXPORTER_OTLP_HEADERS/OTEL_EXPORTER_OTLP_{TRACE,LOG,METRICS}_HEADERS
3 participants