feat(node): Support propagateTraceparent#18476
Conversation
size-limit report 📦
|
This comment was marked as outdated.
This comment was marked as outdated.
…etsentry/sentry-javascript into timfish/feat/node-propagateTraceparent
Lms24
left a comment
There was a problem hiding this comment.
Thanks! Let's make sure we test this for fetch and http in node-core and node. AFAIK we have a different propagation mechanism for http in node than in node-core. If this is not the case and the tests would be pure duplication, feel free to skip :)
There was a problem hiding this comment.
Bug: Propagator fields() doesn't include injected traceparent header
The fields() method returns only sentry-trace and baggage headers, but the propagator now also injects the traceparent header when propagateTraceparent is enabled. According to the OpenTelemetry TextMapPropagator specification, fields() should return all headers that the propagator may potentially modify, which is used for CORS configuration and carrier pre-allocation. Since traceparent can now be injected, it should be included in the returned array. While the PR documentation warns users to configure CORS manually, omitting traceparent from fields() violates the propagator contract and could cause issues for code that relies on this method to determine which headers might be set.
packages/opentelemetry/src/propagator.ts#L121-L124
sentry-javascript/packages/opentelemetry/src/propagator.ts
Lines 121 to 124 in 4134dab
| public fields(): string[] { | ||
| return [SENTRY_TRACE_HEADER, SENTRY_BAGGAGE_HEADER]; | ||
| return [SENTRY_TRACE_HEADER, SENTRY_BAGGAGE_HEADER, 'traceparent']; | ||
| } |
There was a problem hiding this comment.
Bug: Propagator fields() unconditionally claims conditional header
The fields() method now unconditionally returns 'traceparent' in its array, but the inject() method only actually sets the traceparent header when propagateTraceparent is true. This mismatch between declared fields and actual injection behavior could cause coordination issues with other propagators in a composite setup. When propagateTraceparent is false, the propagator claims ownership of traceparent but never injects it, potentially preventing other propagators from injecting this header.
There was a problem hiding this comment.
hmm looks like we use fields somewhat incorrectly anyway 🤔 So probably fine to disregard for now
This PR:
propagateTraceparentto base optionstraceparentsupport to the OtelgetTraceDataCloses #18465