Skip to content

[instrumentation-undici] Traceparent not propagated correctly when header already exist in the request #2796

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
hectorhdzg opened this issue Apr 18, 2025 · 2 comments
Assignees
Labels
bug Something isn't working needs:spec This cannot be implemented without some changes or clarifications in the specification or semconv pkg:instrumentation-undici priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Comments

@hectorhdzg
Copy link
Member

What version of OpenTelemetry are you using?

"@opentelemetry/sdk-node": "^0.200.0"

What version of Node are you using?

18.17.0

What did you do?

Enable undici instrumentation, manually add traceparent to request, make request using fetch

What did you expect to see?

traceparent header is propagated correctly

What did you see instead?

Incorrect format of traceparent causing parseTraceParent in W3CTraceContextPropagator to fail and return null

Ex:
traceparent = "00-5c4f0bdefa3390bbb38cc02bc2766517-7104f40181c58265-01, 00-5c4f0bdefa3390bbb38cc02bc2766517-db1f1457d0e19314-01"

Additional context

Related to
open-telemetry/opentelemetry-js#5590

@dyladan
Copy link
Member

dyladan commented Apr 23, 2025

I took a look at this and there's not an easy way to solve this. I think this requires some specification in order to extend the propagation interface with a shouldInject or similar function.

Add a setter that checks for header existence

If the traceparent already exists but tracestate does not, then tracestate would be injected. This is not what we want because then we're mixing tracing systems in a single request which would be bad.

Propagator checks if headers already exists

There's no way to implement this because there isn't a textmap of existing headers already from undici, and inject doesn't have a getter anyway, only a setter.

@pichlermarc pichlermarc added priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect needs:spec This cannot be implemented without some changes or clarifications in the specification or semconv labels May 7, 2025
@pichlermarc
Copy link
Member

@dyladan opened a Spec issue regarding this: open-telemetry/opentelemetry-specification#4496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:spec This cannot be implemented without some changes or clarifications in the specification or semconv pkg:instrumentation-undici priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
Projects
None yet
Development

No branches or pull requests

4 participants