Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

feat: use specific W3CTraceContextPropagator for OTel#2036

Merged
feywind merged 3 commits intogoogleapis:mainfrom
feywind:feat-otel-w3c-propagator
May 8, 2025
Merged

feat: use specific W3CTraceContextPropagator for OTel#2036
feywind merged 3 commits intogoogleapis:mainfrom
feywind:feat-otel-w3c-propagator

Conversation

@feywind
Copy link
Copy Markdown
Collaborator

@feywind feywind commented May 6, 2025

Replaces the use of the global OpenTelemetry propagator (propagation) with a specific instance of W3CTraceContextPropagator within the telemetry-tracing.ts module.

This ensures that trace context propagation for Pub/Sub messages always uses the W3C format via the googclient_traceparent attribute, regardless of the global propagator configured by user code. This maintains consistent tracing behaviour as it moves between library instances as a Pub/Sub attribute.

Fixes #2005 🦕

Replaces the use of the global OpenTelemetry propagator (`propagation`)
with a specific instance of `W3CTraceContextPropagator` within the
`telemetry-tracing.ts` module.

This ensures that trace context propagation for Pub/Sub messages always
uses the W3C format via the `googclient_traceparent` attribute,
regardless of the global propagator configured by your code. This is
important for maintaining consistent tracing behavior, especially when
context is passed through non-HTTP transports used by the library.

The change involves:
- Importing `W3CTraceContextPropagator` from `@opentelemetry/core`.
- Instantiating the propagator.
- Updating `injectSpan` and `extractSpan` to use the specific instance.

Existing tests pass without modification as they implicitly relied on
the W3C propagator behavior via the test setup's `BasicTracerProvider`.
@feywind feywind requested a review from a team May 6, 2025 21:49
@feywind feywind requested a review from a team as a code owner May 6, 2025 21:49
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: pubsub Issues related to the googleapis/nodejs-pubsub API. labels May 6, 2025
@feywind feywind added owlbot:ignore instruct owl-bot to ignore a PR owlbot:run Add this label to trigger the Owlbot post processor. and removed owlbot:ignore instruct owl-bot to ignore a PR labels May 8, 2025
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 8, 2025
@feywind feywind merged commit c9a9656 into googleapis:main May 8, 2025
14 of 15 checks passed
@feywind feywind deleted the feat-otel-w3c-propagator branch May 8, 2025 21:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: pubsub Issues related to the googleapis/nodejs-pubsub API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenTelemetry support needs to use its own context propagator

2 participants