Skip to content

Commit 93e2253

Browse files
committed
add private option to set meterprovider
1 parent 06256e1 commit 93e2253

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
@@ -77,6 +77,9 @@ type BatchSpanProcessorOptions struct {
7777
// Blocking option should be used carefully as it can severely affect the performance of an
7878
// application.
7979
BlockOnQueueFull bool
80+
81+
// meterProvider is the meterProvider used to record self-observability metrics.
82+
meterProvider metric.MeterProvider
8083
}
8184

8285
// batchSpanProcessor is a SpanProcessor that batches asynchronously-received
@@ -349,6 +352,16 @@ func WithBlocking() BatchSpanProcessorOption {
349352
}
350353
}
351354

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

0 commit comments

Comments
 (0)