From 14325b1a8b70ea390baec97bd4499c04f3a7b814 Mon Sep 17 00:00:00 2001 From: Siim Kallas Date: Fri, 15 Jul 2022 17:56:39 +0300 Subject: [PATCH] fix: set BSP interval to 500ms (#509) --- 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 5ba81068b..4e4309e46 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