Skip to content

Commit fd6f484

Browse files
committed
add private option to set meterprovider
1 parent 5f42d7c commit fd6f484

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sdk/trace/batch_span_processor.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ type BatchSpanProcessorOptions struct {
7575
// Blocking option should be used carefully as it can severely affect the performance of an
7676
// application.
7777
BlockOnQueueFull bool
78+
79+
// meterProvider is the meterProvider used to record self-observability metrics.
80+
meterProvider metric.MeterProvider
7881
}
7982

8083
// batchSpanProcessor is a SpanProcessor that batches asynchronously-received
@@ -347,6 +350,16 @@ func WithBlocking() BatchSpanProcessorOption {
347350
}
348351
}
349352

353+
// withMeterProvider allows configuring the meterProvider used for recording
354+
// self-observability metrics during testing.
355+
func withMeterProvider(provider metric.MeterProvider) BatchSpanProcessorOption {
356+
return func(o *BatchSpanProcessorOptions) {
357+
if provider != nil {
358+
o.meterProvider = provider
359+
}
360+
}
361+
}
362+
350363
// exportSpans is a subroutine of processing and draining the queue.
351364
func (bsp *batchSpanProcessor) exportSpans(ctx context.Context) error {
352365
bsp.timer.Reset(bsp.o.BatchTimeout)

0 commit comments

Comments
 (0)