Skip to content

Commit 0061861

Browse files
committed
Add Functions to Inject/Extract propagation context
1 parent f0e0b9d commit 0061861

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

shared/src/open_telemetry/TracerContext.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Tracer } from "@opentelemetry/api";
1+
import { Tracer, trace, propagation, context } from "@opentelemetry/api";
22
import { TracerStrategy } from "./TracerExporterStrategy";
33

44
/* Holds reference to the tracer exporter strategy, and delegates tasks to the concrete implementation */
@@ -22,5 +22,14 @@ export class TracerContext {
2222
public getTracer(serviceName: string, version: string): Tracer {
2323
return this._tracerStrategy.getTracer(serviceName, version);
2424
}
25+
26+
public InjectPropagation(headers: Record<string, string>): void {
27+
propagation.inject(context.active(), headers);
28+
};
29+
30+
public ExtractPropagation(headers: Record<string, string>): void {
31+
propagation.extract(context.active(), headers || {});
32+
}
33+
2534

2635
}

0 commit comments

Comments
 (0)