diff --git a/CHANGELOG.md b/CHANGELOG.md index fb91daf7486..3d98c758587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/exporters/otlp/otlptrace/internal/otlptracetest/otlptest.go b/exporters/otlp/otlptrace/internal/otlptracetest/otlptest.go index 812b7b42902..945eaac68e3 100644 --- a/exporters/otlp/otlptrace/internal/otlptracetest/otlptest.go +++ b/exporters/otlp/otlptrace/internal/otlptracetest/otlptest.go @@ -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), ), } diff --git a/exporters/otlp/otlptrace/otlptracegrpc/client_test.go b/exporters/otlp/otlptrace/otlptracegrpc/client_test.go index 9a02ca227b6..10128676d78 100644 --- a/exporters/otlp/otlptrace/otlptracegrpc/client_test.go +++ b/exporters/otlp/otlptrace/otlptracegrpc/client_test.go @@ -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), ), ) diff --git a/sdk/trace/batch_span_processor.go b/sdk/trace/batch_span_processor.go index 57f346aa08b..6850c53980e 100644 --- a/sdk/trace/batch_span_processor.go +++ b/sdk/trace/batch_span_processor.go @@ -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. @@ -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, @@ -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{}), } @@ -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 } } @@ -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() @@ -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() diff --git a/sdk/trace/batch_span_processor_test.go b/sdk/trace/batch_span_processor_test.go index f361b535d0f..eedadbd6ec3 100644 --- a/sdk/trace/batch_span_processor_test.go +++ b/sdk/trace/batch_span_processor_test.go @@ -131,18 +131,18 @@ 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, @@ -150,9 +150,9 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) { 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), }, @@ -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), }, @@ -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, @@ -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,