Skip to content

Commit

Permalink
feat(exporter-jaeger): flush data before shutdown (open-telemetry#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 authored Sep 19, 2019
1 parent a9df567 commit 0c61fc2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/opentelemetry-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ export class JaegerExporter implements SpanExporter {

/** Shutdown exporter. */
shutdown(): void {
this._sender.close();
this._sender.flush((numSpans: number, err?: string) => {
if (err) {
this._logger.error(`failed to flush span: ${err}`);
}
});
// Sleeping 2 seconds before closing the sender's connection to ensure all spans are flushed.
setTimeout(() => {
this._sender.close();
}, 2000);
}

/** Transform spans and sends to Jaeger service. */
Expand Down

0 comments on commit 0c61fc2

Please sign in to comment.