Skip to content

Commit

Permalink
fix: override NodeTracerProviders component getters to ensure backwar…
Browse files Browse the repository at this point in the history
…ds compatibility
  • Loading branch information
rauno56 committed Jun 13, 2022
1 parent 0eaee98 commit 49305d5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/opentelemetry-sdk-trace-node/src/NodeTracerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,18 @@ export class NodeTracerProvider extends BasicTracerProvider {
super.register(config);
}

protected override _getPropagator(name: string): TextMapPropagator | undefined {
// TODO: remove this. Overwriting _registered* is sufficient
// Do not override either of the getters in your child class unless you really need to.
// We have to do it here because the previous version of BasicTracerProvider's getters
// had BasicTracerProvider's static method hardcoded.
protected _getPropagator(name: string): TextMapPropagator | undefined {
return (
super._getPropagator(name) ||
NodeTracerProvider._registeredPropagators.get(name)?.()
);
(this.constructor as any)._registeredPropagators as typeof BasicTracerProvider._registeredPropagators
).get(name)?.();
}

protected _getSpanExporter(name: string): SpanExporter | undefined {
return (
(this.constructor as any)._registeredExporters as typeof BasicTracerProvider._registeredExporters
).get(name)?.();
}
}

0 comments on commit 49305d5

Please sign in to comment.