1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-07-13 01:00:22 +02:00
Files
Corentin 86640ceae0 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 <42@dmathieu.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2025-07-09 11:18:17 +02:00
..
2024-03-26 20:13:54 +01:00
2025-06-17 16:49:22 +02:00

SDK Trace

PkgGoDev