Skip to content

Commit 86640ce

Browse files
corentinmusarddmathieupellared
authored
Clarify DefaultMaxQueueSize and DefaultScheduleDelay usage (#6974)
### 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 <[email protected]> Co-authored-by: Robert Pająk <[email protected]>
1 parent afd4763 commit 86640ce

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sdk/trace/batch_span_processor.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ import (
1818

1919
// Defaults for BatchSpanProcessorOptions.
2020
const (
21-
DefaultMaxQueueSize = 2048
22-
DefaultScheduleDelay = 5000
21+
DefaultMaxQueueSize = 2048
22+
// DefaultScheduleDelay is the delay interval between two consecutive exports, in milliseconds.
23+
DefaultScheduleDelay = 5000
24+
// DefaultExportTimeout is the duration after which an export is cancelled, in milliseconds.
2325
DefaultExportTimeout = 30000
2426
DefaultMaxExportBatchSize = 512
2527
)

0 commit comments

Comments
 (0)