Skip to content

Commit 7134f27

Browse files
committed
address comments
1 parent 885da03 commit 7134f27

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

sdk/trace/batch_span_processor.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ func NewBatchSpanProcessor(exporter SpanExporter, options ...BatchSpanProcessorO
139139
return bsp
140140
}
141141

142-
var processorID atomic.Int64
142+
var processorIDCounter atomic.Int64
143143

144-
// nextProcessorID returns an identifier for this batch span processor,
144+
// nextprocessorIDCounter returns an identifier for this batch span processor,
145145
// starting with 0 and incrementing by 1 each time it is called.
146-
func nextProcessorID() int64 {
147-
return processorID.Add(1) - 1
146+
func nextprocessorIDCounter() int64 {
147+
return processorIDCounter.Add(1) - 1
148148
}
149149

150150
// configureSelfObservability configures metrics for the batch span processor.
@@ -154,7 +154,7 @@ func (bsp *batchSpanProcessor) configureSelfObservability() {
154154
}
155155
bsp.selfObservabilityEnabled = true
156156
bsp.componentNameAttr = semconv.OTelComponentName(
157-
fmt.Sprintf("%s/%d", otelconv.ComponentTypeBatchingSpanProcessor, nextProcessorID()))
157+
fmt.Sprintf("%s/%d", otelconv.ComponentTypeBatchingSpanProcessor, nextprocessorIDCounter()))
158158
meter := otel.GetMeterProvider().Meter(
159159
selfObsScopeName,
160160
metric.WithInstrumentationVersion(sdk.Version()),

sdk/trace/batch_span_processor_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"encoding/binary"
99
"errors"
1010
"fmt"
11+
"runtime"
1112
"sync"
1213
"sync/atomic"
1314
"testing"
@@ -872,7 +873,7 @@ func (e *blockingExporter) ExportSpans(ctx context.Context, s []ReadOnlySpan) er
872873

873874
func (e *blockingExporter) waitForSpans(n int32) {
874875
// Wait for all n spans to reach the export call
875-
// nolint: revive // intentionally empty block
876876
for e.total.Load() < n {
877+
runtime.Gosched()
877878
}
878879
}

0 commit comments

Comments
 (0)