Skip to content

Commit

Permalink
refactor(contrib-test-utils): Migrate away from deprecated `addSpanPr…
Browse files Browse the repository at this point in the history
…ocessor` (#2660)
  • Loading branch information
chancancode authored Jan 22, 2025
1 parent c67a8c3 commit 1dace2f
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,23 @@ import {
export const registerInstrumentationTestingProvider = (
config?: NodeTracerConfig
): NodeTracerProvider => {
const otelTestingProvider = new NodeTracerProvider(config);
const spanProcessors = config?.spanProcessors
? [...config.spanProcessors]
: [];

setTestMemoryExporter(new InMemorySpanExporter());
otelTestingProvider.addSpanProcessor(
new SimpleSpanProcessor(getTestMemoryExporter()!)
);

spanProcessors.push(new SimpleSpanProcessor(getTestMemoryExporter()!));

if (process.env.OTEL_EXPORTER_JAEGER_AGENT_HOST) {
otelTestingProvider.addSpanProcessor(
new SimpleSpanProcessor(new JaegerExporter())
);
spanProcessors.push(new SimpleSpanProcessor(new JaegerExporter()));
}

const otelTestingProvider = new NodeTracerProvider({
...config,
spanProcessors,
});

otelTestingProvider.register();
return otelTestingProvider;
};

0 comments on commit 1dace2f

Please sign in to comment.