Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multi span processor should flush child span processors #1024

Merged
merged 2 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
dyladan marked this conversation as resolved.
Show resolved Hide resolved
}
}

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);
});
});