mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-03 22:52:30 +02:00
Rename ScheduleDelayMillis to BatchTimeout (#752)
Co-authored-by: Joshua MacDonald <jmacd@users.noreply.github.com>
This commit is contained in:
parent
19ee7b7a97
commit
244ed23e44
@ -49,7 +49,7 @@ func initTracer(url string) {
|
||||
tp, err := sdktrace.NewProvider(
|
||||
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
|
||||
sdktrace.WithBatcher(exporter,
|
||||
sdktrace.WithScheduleDelayMillis(5),
|
||||
sdktrace.WithBatchTimeout(5),
|
||||
sdktrace.WithMaxExportBatchSize(10),
|
||||
),
|
||||
)
|
||||
|
@ -39,7 +39,7 @@ func Example_insecure() {
|
||||
tp, _ := sdktrace.NewProvider(
|
||||
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
|
||||
sdktrace.WithBatcher(exp, // add following two options to ensure flush
|
||||
sdktrace.WithScheduleDelayMillis(5),
|
||||
sdktrace.WithBatchTimeout(5),
|
||||
sdktrace.WithMaxExportBatchSize(10),
|
||||
))
|
||||
if err != nil {
|
||||
@ -80,7 +80,7 @@ func Example_withTLS() {
|
||||
tp, err := sdktrace.NewProvider(
|
||||
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
|
||||
sdktrace.WithBatcher(exp, // add following two options to ensure flush
|
||||
sdktrace.WithScheduleDelayMillis(5),
|
||||
sdktrace.WithBatchTimeout(5),
|
||||
sdktrace.WithMaxExportBatchSize(10),
|
||||
))
|
||||
if err != nil {
|
||||
|
@ -81,7 +81,7 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlp.ExporterOption)
|
||||
pOpts := []sdktrace.ProviderOption{
|
||||
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}),
|
||||
sdktrace.WithBatcher(exp, // add following two options to ensure flush
|
||||
sdktrace.WithScheduleDelayMillis(15),
|
||||
sdktrace.WithBatchTimeout(15),
|
||||
sdktrace.WithMaxExportBatchSize(10),
|
||||
),
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
|
||||
const (
|
||||
DefaultMaxQueueSize = 2048
|
||||
DefaultScheduledDelay = 5000 * time.Millisecond
|
||||
DefaultBatchTimeout = 5000 * time.Millisecond
|
||||
DefaultMaxExportBatchSize = 512
|
||||
)
|
||||
|
||||
@ -43,10 +43,10 @@ type BatchSpanProcessorOptions struct {
|
||||
// The default value of MaxQueueSize is 2048.
|
||||
MaxQueueSize int
|
||||
|
||||
// ScheduledDelayMillis is the delay interval in milliseconds between two consecutive
|
||||
// processing of batches.
|
||||
// The default value of ScheduledDelayMillis is 5000 msec.
|
||||
ScheduledDelayMillis time.Duration
|
||||
// BatchTimeout 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
|
||||
|
||||
// MaxExportBatchSize is the maximum number of spans to process in a single batch.
|
||||
// If there are more than one batch worth of spans then it processes multiple batches
|
||||
@ -90,9 +90,9 @@ func NewBatchSpanProcessor(e export.SpanBatcher, opts ...BatchSpanProcessorOptio
|
||||
}
|
||||
|
||||
o := BatchSpanProcessorOptions{
|
||||
ScheduledDelayMillis: DefaultScheduledDelay,
|
||||
MaxQueueSize: DefaultMaxQueueSize,
|
||||
MaxExportBatchSize: DefaultMaxExportBatchSize,
|
||||
BatchTimeout: DefaultBatchTimeout,
|
||||
MaxQueueSize: DefaultMaxQueueSize,
|
||||
MaxExportBatchSize: DefaultMaxExportBatchSize,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(&o)
|
||||
@ -101,7 +101,7 @@ func NewBatchSpanProcessor(e export.SpanBatcher, opts ...BatchSpanProcessorOptio
|
||||
e: e,
|
||||
o: o,
|
||||
batch: make([]*export.SpanData, 0, o.MaxExportBatchSize),
|
||||
timer: time.NewTimer(o.ScheduledDelayMillis),
|
||||
timer: time.NewTimer(o.BatchTimeout),
|
||||
queue: make(chan *export.SpanData, o.MaxQueueSize),
|
||||
stopCh: make(chan struct{}),
|
||||
}
|
||||
@ -147,9 +147,9 @@ func WithMaxExportBatchSize(size int) BatchSpanProcessorOption {
|
||||
}
|
||||
}
|
||||
|
||||
func WithScheduleDelayMillis(delay time.Duration) BatchSpanProcessorOption {
|
||||
func WithBatchTimeout(delay time.Duration) BatchSpanProcessorOption {
|
||||
return func(o *BatchSpanProcessorOptions) {
|
||||
o.ScheduledDelayMillis = delay
|
||||
o.BatchTimeout = delay
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ func WithBlocking() BatchSpanProcessorOption {
|
||||
|
||||
// exportSpans is a subroutine of processing and draining the queue.
|
||||
func (bsp *BatchSpanProcessor) exportSpans() {
|
||||
bsp.timer.Reset(bsp.o.ScheduledDelayMillis)
|
||||
bsp.timer.Reset(bsp.o.BatchTimeout)
|
||||
|
||||
if len(bsp.batch) > 0 {
|
||||
bsp.e.ExportSpans(context.Background(), bsp.batch)
|
||||
@ -171,7 +171,7 @@ func (bsp *BatchSpanProcessor) exportSpans() {
|
||||
|
||||
// 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 ScheduledDelayMillis to form a batch.
|
||||
// waiting up to BatchTimeout to form a batch.
|
||||
func (bsp *BatchSpanProcessor) processQueue() {
|
||||
defer bsp.stopWait.Done()
|
||||
defer bsp.timer.Stop()
|
||||
|
@ -82,18 +82,18 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
|
||||
genNumSpans: 2053,
|
||||
},
|
||||
{
|
||||
name: "non-default ScheduledDelayMillis",
|
||||
name: "non-default BatchTimeout",
|
||||
o: []sdktrace.BatchSpanProcessorOption{
|
||||
sdktrace.WithScheduleDelayMillis(schDelay),
|
||||
sdktrace.WithBatchTimeout(schDelay),
|
||||
},
|
||||
wantNumSpans: 2053,
|
||||
wantBatchCount: 4,
|
||||
genNumSpans: 2053,
|
||||
},
|
||||
{
|
||||
name: "non-default MaxQueueSize and ScheduledDelayMillis",
|
||||
name: "non-default MaxQueueSize and BatchTimeout",
|
||||
o: []sdktrace.BatchSpanProcessorOption{
|
||||
sdktrace.WithScheduleDelayMillis(schDelay),
|
||||
sdktrace.WithBatchTimeout(schDelay),
|
||||
sdktrace.WithMaxQueueSize(200),
|
||||
},
|
||||
wantNumSpans: 205,
|
||||
@ -101,9 +101,9 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
|
||||
genNumSpans: 205,
|
||||
},
|
||||
{
|
||||
name: "non-default MaxQueueSize, ScheduledDelayMillis and MaxExportBatchSize",
|
||||
name: "non-default MaxQueueSize, BatchTimeout and MaxExportBatchSize",
|
||||
o: []sdktrace.BatchSpanProcessorOption{
|
||||
sdktrace.WithScheduleDelayMillis(schDelay),
|
||||
sdktrace.WithBatchTimeout(schDelay),
|
||||
sdktrace.WithMaxQueueSize(205),
|
||||
sdktrace.WithMaxExportBatchSize(20),
|
||||
},
|
||||
@ -114,7 +114,7 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
|
||||
{
|
||||
name: "blocking option",
|
||||
o: []sdktrace.BatchSpanProcessorOption{
|
||||
sdktrace.WithScheduleDelayMillis(schDelay),
|
||||
sdktrace.WithBatchTimeout(schDelay),
|
||||
sdktrace.WithMaxQueueSize(200),
|
||||
sdktrace.WithMaxExportBatchSize(20),
|
||||
sdktrace.WithBlocking(),
|
||||
@ -126,7 +126,7 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
|
||||
{
|
||||
name: "parallel span generation",
|
||||
o: []sdktrace.BatchSpanProcessorOption{
|
||||
sdktrace.WithScheduleDelayMillis(schDelay),
|
||||
sdktrace.WithBatchTimeout(schDelay),
|
||||
sdktrace.WithMaxQueueSize(200),
|
||||
},
|
||||
wantNumSpans: 205,
|
||||
@ -137,7 +137,7 @@ func TestNewBatchSpanProcessorWithOptions(t *testing.T) {
|
||||
{
|
||||
name: "parallel span blocking",
|
||||
o: []sdktrace.BatchSpanProcessorOption{
|
||||
sdktrace.WithScheduleDelayMillis(schDelay),
|
||||
sdktrace.WithBatchTimeout(schDelay),
|
||||
sdktrace.WithMaxExportBatchSize(200),
|
||||
sdktrace.WithBlocking(),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user