Skip to content

Commit

Permalink
feat(otlp-exporter-http): restore bsp timeout logic
Browse files Browse the repository at this point in the history
Signed-off-by: Svetlana Brennan <[email protected]>
  • Loading branch information
svetlanabrennan committed Feb 16, 2022
1 parent fcfd6fa commit dbce62e
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ export abstract class BatchSpanProcessorBase<T extends BufferConfig> implements
return Promise.resolve();
}
return new Promise((resolve, reject) => {
const timer = setTimeout(() => {
// don't wait anymore for export, this way the next batch can start
reject(new Error('Timeout'));
}, this._exportTimeoutMillis);
// prevent downstream exporter calls from generating spans
context.with(suppressTracing(context.active()), () => {
// Reset the finished spans buffer here because the next invocations of the _flush method
Expand All @@ -151,6 +155,7 @@ export abstract class BatchSpanProcessorBase<T extends BufferConfig> implements
this._exporter.export(
this._finishedSpans.splice(0, this._maxExportBatchSize),
result => {
clearTimeout(timer);
if (result.code === ExportResultCode.SUCCESS) {
resolve();
} else {
Expand All @@ -159,9 +164,7 @@ export abstract class BatchSpanProcessorBase<T extends BufferConfig> implements
new Error('BatchSpanProcessor: span export failed')
);
}
},
this._exportTimeoutMillis,
reject
}
);
});
});
Expand Down

0 comments on commit dbce62e

Please sign in to comment.