@@ -19,14 +19,14 @@ import {
1919 Span ,
2020 context ,
2121 trace ,
22- propagation ,
2322 SpanKind ,
2423 TextMapGetter ,
2524 TextMapSetter ,
2625 ROOT_CONTEXT ,
2726 Context ,
2827 Link ,
2928} from '@opentelemetry/api' ;
29+ import { W3CTraceContextPropagator } from '@opentelemetry/core' ;
3030import { Attributes , PubsubMessage } from './publisher/pubsub-message' ;
3131import { Duration } from './temporal' ;
3232
@@ -70,6 +70,14 @@ export enum OpenTelemetryLevel {
7070 Modern = 2 ,
7171}
7272
73+ /**
74+ * The W3C trace context propagator, used for injecting/extracting trace context.
75+ *
76+ * @private
77+ * @internal
78+ */
79+ const w3cTraceContextPropagator = new W3CTraceContextPropagator ( ) ;
80+
7381// True if user code elsewhere wants to enable OpenTelemetry support.
7482let globallyEnabled = false ;
7583
@@ -749,7 +757,7 @@ export function injectSpan(span: Span, message: MessageWithAttributes): void {
749757
750758 // Always do propagation injection with the trace context.
751759 const context = trace . setSpanContext ( ROOT_CONTEXT , span . spanContext ( ) ) ;
752- propagation . inject ( context , message , pubsubSetter ) ;
760+ w3cTraceContextPropagator . inject ( context , message , pubsubSetter ) ;
753761
754762 // Also put the direct reference to the Span object for while we're
755763 // passing it around in the client library.
@@ -802,7 +810,11 @@ export function extractSpan(
802810 let context : Context | undefined ;
803811
804812 if ( keys . includes ( modernAttributeName ) ) {
805- context = propagation . extract ( ROOT_CONTEXT , message , pubsubGetter ) ;
813+ context = w3cTraceContextPropagator . extract (
814+ ROOT_CONTEXT ,
815+ message ,
816+ pubsubGetter ,
817+ ) ;
806818 }
807819
808820 const span = PubsubSpans . createReceiveSpan (
0 commit comments