From c80282dbfa6bc6c1e90855896371f07578a2ebfc Mon Sep 17 00:00:00 2001 From: Siim Kallas Date: Fri, 15 Jul 2022 17:14:57 +0300 Subject: [PATCH] fix: set BSP interval to 500ms --- src/tracing/options.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tracing/options.ts b/src/tracing/options.ts index 5ba81068..4e4309e4 100644 --- a/src/tracing/options.ts +++ b/src/tracing/options.ts @@ -239,8 +239,21 @@ const SpanExporterMap: Record = { 'otlp-grpc': otlpSpanExporterFactory, }; +// Temporary workaround until https://github.com/open-telemetry/opentelemetry-js/issues/3094 is resolved +function getBatchSpanProcessorConfig() { + // OTel uses its own parsed environment, we can just use the default env if the BSP delay is unset. + if (process.env.OTEL_BSP_SCHEDULE_DELAY !== undefined) { + return undefined; + } + + return { scheduledDelayMillis: 500 }; +} + export function defaultSpanProcessorFactory(options: Options): SpanProcessor { - return new SplunkBatchSpanProcessor(options.spanExporterFactory(options)); + return new SplunkBatchSpanProcessor( + options.spanExporterFactory(options), + getBatchSpanProcessorConfig() + ); } // eslint-disable-next-line @typescript-eslint/no-unused-vars