From 86640ceae052242787a1efb185d9b547ded41d68 Mon Sep 17 00:00:00 2001 From: Corentin <33163342+corentinmusard@users.noreply.github.com> Date: Wed, 9 Jul 2025 09:18:17 +0000 Subject: [PATCH] Clarify DefaultMaxQueueSize and DefaultScheduleDelay usage (#6974) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description OpenTelemetry uses `DefaultScheduleDelay` and `DefaultExportTimeout` values as milliseconds but Go time package will understand them as nanoseconds. I understand that this is a stable library and that those value will probably never change, so can we at least clarify their usage? Right above the defaults declaration it says `// Defaults for BatchSpanProcessorOptions.` which is confusing. We used `trace.DefaultScheduleDelay` as a fallback value for our tracing setup. This confusion led to high CPU usage due to the frequent batch exports. ### Confusing behavior ```go processor := trace.NewBatchSpanProcessor(exporter, // set timeout to 5000 ns instead of the expected 5000 ms trace.WithBatchTimeout(trace.DefaultScheduleDelay), // set timeout to 30000 ns instead of the expected 30000 ms trace.WithExportTimeout(trace.DefaultExportTimeout), ) ``` ### Correct way to use those values ```go processor := trace.NewBatchSpanProcessor(exporter, trace.WithBatchTimeout(trace.DefaultScheduleDelay * time.Millisecond), trace.WithExportTimeout(trace.DefaultExportTimeout * time.Millisecond), ) ``` --------- Co-authored-by: Damien Mathieu <42@dmathieu.com> Co-authored-by: Robert PajÄ…k --- sdk/trace/batch_span_processor.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/trace/batch_span_processor.go b/sdk/trace/batch_span_processor.go index 6966ed861..b6e93dea0 100644 --- a/sdk/trace/batch_span_processor.go +++ b/sdk/trace/batch_span_processor.go @@ -18,8 +18,10 @@ import ( // Defaults for BatchSpanProcessorOptions. const ( - DefaultMaxQueueSize = 2048 - DefaultScheduleDelay = 5000 + DefaultMaxQueueSize = 2048 + // DefaultScheduleDelay is the delay interval between two consecutive exports, in milliseconds. + DefaultScheduleDelay = 5000 + // DefaultExportTimeout is the duration after which an export is cancelled, in milliseconds. DefaultExportTimeout = 30000 DefaultMaxExportBatchSize = 512 )