Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename BatchTimeout to ScheduleDelay #2564

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Changed

- Jaeger exporter takes into additional 70 bytes overhead into consideration when sending UDP packets (#2489, #2512)
- Renamed `BatchTimeout` to `ScheduleDelay` in batch span processor (#2564)

### Deprecated

Expand Down
Expand Up @@ -34,7 +34,7 @@ func RunEndToEndTest(ctx context.Context, t *testing.T, exp *otlptrace.Exporter,
sdktrace.WithBatcher(
exp,
// add following two options to ensure flush
sdktrace.WithBatchTimeout(5*time.Second),
sdktrace.WithScheduleDelay(5*time.Second),
sdktrace.WithMaxExportBatchSize(10),
),
}
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlptrace/otlptracegrpc/client_test.go
Expand Up @@ -254,7 +254,7 @@ func TestNew_withMultipleAttributeTypes(t *testing.T) {
sdktrace.WithBatcher(
exp,
// add following two options to ensure flush
sdktrace.WithBatchTimeout(5*time.Second),
sdktrace.WithScheduleDelay(5*time.Second),
sdktrace.WithMaxExportBatchSize(10),
),
)
Expand Down
18 changes: 9 additions & 9 deletions sdk/trace/batch_span_processor.go
Expand Up @@ -42,10 +42,10 @@ type BatchSpanProcessorOptions struct {
// The default value of MaxQueueSize is 2048.
MaxQueueSize int

// BatchTimeout is the maximum duration for constructing a batch. Processor
// ScheduleDelay is the maximum duration for constructing a batch. Processor
// forcefully sends available spans when timeout is reached.
// The default value of BatchTimeout is 5000 msec.
BatchTimeout time.Duration
// The default value of ScheduleDelay is 5000 msec.
ScheduleDelay time.Duration

// ExportTimeout specifies the maximum duration for exporting spans. If the timeout
// is reached, the export will be cancelled.
Expand Down Expand Up @@ -101,7 +101,7 @@ func NewBatchSpanProcessor(exporter SpanExporter, options ...BatchSpanProcessorO
}

o := BatchSpanProcessorOptions{
BatchTimeout: time.Duration(intEnvOr(EnvBatchSpanProcessorScheduleDelay, DefaultScheduleDelay)) * time.Millisecond,
ScheduleDelay: time.Duration(intEnvOr(EnvBatchSpanProcessorScheduleDelay, DefaultScheduleDelay)) * time.Millisecond,
ExportTimeout: time.Duration(intEnvOr(EnvBatchSpanProcessorExportTimeout, DefaultExportTimeout)) * time.Millisecond,
MaxQueueSize: maxQueueSize,
MaxExportBatchSize: maxExportBatchSize,
Expand All @@ -113,7 +113,7 @@ func NewBatchSpanProcessor(exporter SpanExporter, options ...BatchSpanProcessorO
e: exporter,
o: o,
batch: make([]ReadOnlySpan, 0, o.MaxExportBatchSize),
timer: time.NewTimer(o.BatchTimeout),
timer: time.NewTimer(o.ScheduleDelay),
queue: make(chan ReadOnlySpan, o.MaxQueueSize),
stopCh: make(chan struct{}),
}
Expand Down Expand Up @@ -216,9 +216,9 @@ func WithMaxExportBatchSize(size int) BatchSpanProcessorOption {
}
}

func WithBatchTimeout(delay time.Duration) BatchSpanProcessorOption {
func WithScheduleDelay(delay time.Duration) BatchSpanProcessorOption {
return func(o *BatchSpanProcessorOptions) {
o.BatchTimeout = delay
o.ScheduleDelay = delay
}
}

Expand All @@ -237,7 +237,7 @@ func WithBlocking() BatchSpanProcessorOption {
// exportSpans is a subroutine of processing and draining the queue.
func (bsp *batchSpanProcessor) exportSpans(ctx context.Context) error {

bsp.timer.Reset(bsp.o.BatchTimeout)
bsp.timer.Reset(bsp.o.ScheduleDelay)

bsp.batchMutex.Lock()
defer bsp.batchMutex.Unlock()
Expand Down Expand Up @@ -267,7 +267,7 @@ func (bsp *batchSpanProcessor) exportSpans(ctx context.Context) error {

// processQueue removes spans from the `queue` channel until processor
// is shut down. It calls the exporter in batches of up to MaxExportBatchSize
// waiting up to BatchTimeout to form a batch.
// waiting up to ScheduleDelay to form a batch.
func (bsp *batchSpanProcessor) processQueue() {
defer bsp.timer.Stop()

Expand Down
18 changes: 9 additions & 9 deletions sdk/trace/batch_span_processor_test.go
Expand Up @@ -131,28 +131,28 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
genNumSpans: 2053,
},
{
name: "non-default BatchTimeout",
name: "non-default ScheduleDelay",
o: []sdktrace.BatchSpanProcessorOption{
sdktrace.WithBatchTimeout(schDelay),
sdktrace.WithScheduleDelay(schDelay),
},
wantNumSpans: 2053,
wantBatchCount: 4,
genNumSpans: 2053,
},
{
name: "non-default MaxQueueSize and BatchTimeout",
name: "non-default MaxQueueSize and ScheduleDelay",
o: []sdktrace.BatchSpanProcessorOption{
sdktrace.WithBatchTimeout(schDelay),
sdktrace.WithScheduleDelay(schDelay),
sdktrace.WithMaxQueueSize(200),
},
wantNumSpans: 205,
wantBatchCount: 1,
genNumSpans: 205,
},
{
name: "non-default MaxQueueSize, BatchTimeout and MaxExportBatchSize",
name: "non-default MaxQueueSize, ScheduleDelay and MaxExportBatchSize",
o: []sdktrace.BatchSpanProcessorOption{
sdktrace.WithBatchTimeout(schDelay),
sdktrace.WithScheduleDelay(schDelay),
sdktrace.WithMaxQueueSize(205),
sdktrace.WithMaxExportBatchSize(20),
},
Expand All @@ -163,7 +163,7 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
{
name: "blocking option",
o: []sdktrace.BatchSpanProcessorOption{
sdktrace.WithBatchTimeout(schDelay),
sdktrace.WithScheduleDelay(schDelay),
sdktrace.WithMaxQueueSize(200),
sdktrace.WithMaxExportBatchSize(20),
},
Expand All @@ -174,7 +174,7 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
{
name: "parallel span generation",
o: []sdktrace.BatchSpanProcessorOption{
sdktrace.WithBatchTimeout(schDelay),
sdktrace.WithScheduleDelay(schDelay),
sdktrace.WithMaxQueueSize(200),
},
wantNumSpans: 205,
Expand All @@ -185,7 +185,7 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
{
name: "parallel span blocking",
o: []sdktrace.BatchSpanProcessorOption{
sdktrace.WithBatchTimeout(schDelay),
sdktrace.WithScheduleDelay(schDelay),
sdktrace.WithMaxExportBatchSize(200),
},
wantNumSpans: 2000,
Expand Down