@@ -32,7 +32,7 @@ import { SpanExporter } from './SpanExporter';
3232 * Implementation of the {@link SpanProcessor} that batches spans exported by
3333 * the SDK then pushes them to the exporter pipeline.
3434 */
35- export class BatchSpanProcessor implements SpanProcessor {
35+ export abstract class BatchSpanProcessorBase < T extends BufferConfig > implements SpanProcessor {
3636 private readonly _maxExportBatchSize : number ;
3737 private readonly _maxQueueSize : number ;
3838 private readonly _scheduledDelayMillis : number ;
@@ -43,23 +43,23 @@ export class BatchSpanProcessor implements SpanProcessor {
4343 private _isShutdown = false ;
4444 private _shuttingDownPromise : Promise < void > = Promise . resolve ( ) ;
4545
46- constructor ( private readonly _exporter : SpanExporter , config ?: BufferConfig ) {
46+ constructor ( private readonly _exporter : SpanExporter , config ?: T ) {
4747 const env = getEnv ( ) ;
4848 this . _maxExportBatchSize =
4949 typeof config ?. maxExportBatchSize === 'number'
5050 ? config . maxExportBatchSize
5151 : env . OTEL_BSP_MAX_EXPORT_BATCH_SIZE ;
5252 this . _maxQueueSize =
5353 typeof config ?. maxQueueSize === 'number'
54- ? config ? .maxQueueSize
54+ ? config . maxQueueSize
5555 : env . OTEL_BSP_MAX_QUEUE_SIZE ;
5656 this . _scheduledDelayMillis =
5757 typeof config ?. scheduledDelayMillis === 'number'
58- ? config ? .scheduledDelayMillis
58+ ? config . scheduledDelayMillis
5959 : env . OTEL_BSP_SCHEDULE_DELAY ;
6060 this . _exportTimeoutMillis =
6161 typeof config ?. exportTimeoutMillis === 'number'
62- ? config ? .exportTimeoutMillis
62+ ? config . exportTimeoutMillis
6363 : env . OTEL_BSP_EXPORT_TIMEOUT ;
6464 }
6565
@@ -87,6 +87,9 @@ export class BatchSpanProcessor implements SpanProcessor {
8787 this . _isShutdown = true ;
8888 this . _shuttingDownPromise = new Promise ( ( resolve , reject ) => {
8989 Promise . resolve ( )
90+ . then ( ( ) => {
91+ return this . onShutdown ( ) ;
92+ } )
9093 . then ( ( ) => {
9194 return this . _flushAll ( ) ;
9295 } )
@@ -190,4 +193,6 @@ export class BatchSpanProcessor implements SpanProcessor {
190193 this . _timer = undefined ;
191194 }
192195 }
196+
197+ protected abstract onShutdown ( ) : void ;
193198}
0 commit comments