Skip to content

Commit

Permalink
fix: multi span processor should flush child span processors (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
legendecas committed May 6, 2020
1 parent c1bcce8 commit 2b14af3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/opentelemetry-tracing/src/MultiSpanProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export class MultiSpanProcessor implements SpanProcessor {
constructor(private readonly _spanProcessors: SpanProcessor[]) {}

forceFlush(): void {
// do nothing as all spans are being exported without waiting
for (const spanProcessor of this._spanProcessors) {
spanProcessor.forceFlush();
}
}

onStart(span: Span): void {
Expand Down
15 changes: 15 additions & 0 deletions packages/opentelemetry-tracing/test/MultiSpanProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,19 @@ describe('MultiSpanProcessor', () => {
assert.strictEqual(processor1.spans.length, 0);
assert.strictEqual(processor1.spans.length, processor2.spans.length);
});

it('should force span processors to flush', () => {
let flushed = false;
const processor: SpanProcessor = {
forceFlush: () => {
flushed = true;
},
onStart: span => {},
onEnd: span => {},
shutdown: () => {},
};
const multiSpanProcessor = new MultiSpanProcessor([processor]);
multiSpanProcessor.forceFlush();
assert.ok(flushed);
});
});

0 comments on commit 2b14af3

Please sign in to comment.