@@ -57,9 +57,9 @@ type BatchSpanProcessorOptions struct {
5757 BlockOnQueueFull bool
5858}
5959
60- // BatchSpanProcessor is a SpanProcessor that batches asynchronously-received
60+ // batchSpanProcessor is a SpanProcessor that batches asynchronously-received
6161// SpanSnapshots and sends them to a trace.Exporter when complete.
62- type BatchSpanProcessor struct {
62+ type batchSpanProcessor struct {
6363 e export.SpanExporter
6464 o BatchSpanProcessorOptions
6565
@@ -74,16 +74,13 @@ type BatchSpanProcessor struct {
7474 stopCh chan struct {}
7575}
7676
77- var _ SpanProcessor = (* BatchSpanProcessor )(nil )
77+ var _ SpanProcessor = (* batchSpanProcessor )(nil )
7878
79- // NewBatchSpanProcessor creates a new BatchSpanProcessor that will send
80- // SpanSnapshot batches to the exporters with the supplied options.
81- //
82- // The returned BatchSpanProcessor needs to be registered with the SDK using
83- // the RegisterSpanProcessor method for it to process spans.
79+ // NewBatchSpanProcessor creates a new SpanProcessor that will send completed
80+ // span batches to the exporter with the supplied options.
8481//
8582// If the exporter is nil, the span processor will preform no action.
86- func NewBatchSpanProcessor (exporter export.SpanExporter , options ... BatchSpanProcessorOption ) * BatchSpanProcessor {
83+ func NewBatchSpanProcessor (exporter export.SpanExporter , options ... BatchSpanProcessorOption ) SpanProcessor {
8784 o := BatchSpanProcessorOptions {
8885 BatchTimeout : DefaultBatchTimeout ,
8986 MaxQueueSize : DefaultMaxQueueSize ,
@@ -92,7 +89,7 @@ func NewBatchSpanProcessor(exporter export.SpanExporter, options ...BatchSpanPro
9289 for _ , opt := range options {
9390 opt (& o )
9491 }
95- bsp := & BatchSpanProcessor {
92+ bsp := & batchSpanProcessor {
9693 e : exporter ,
9794 o : o ,
9895 batch : make ([]* export.SpanSnapshot , 0 , o .MaxExportBatchSize ),
@@ -112,10 +109,10 @@ func NewBatchSpanProcessor(exporter export.SpanExporter, options ...BatchSpanPro
112109}
113110
114111// OnStart method does nothing.
115- func (bsp * BatchSpanProcessor ) OnStart (parent context.Context , s ReadWriteSpan ) {}
112+ func (bsp * batchSpanProcessor ) OnStart (parent context.Context , s ReadWriteSpan ) {}
116113
117114// OnEnd method enqueues a ReadOnlySpan for later processing.
118- func (bsp * BatchSpanProcessor ) OnEnd (s ReadOnlySpan ) {
115+ func (bsp * batchSpanProcessor ) OnEnd (s ReadOnlySpan ) {
119116 // Do not enqueue spans if we are just going to drop them.
120117 if bsp .e == nil {
121118 return
@@ -125,7 +122,7 @@ func (bsp *BatchSpanProcessor) OnEnd(s ReadOnlySpan) {
125122
126123// Shutdown flushes the queue and waits until all spans are processed.
127124// It only executes once. Subsequent call does nothing.
128- func (bsp * BatchSpanProcessor ) Shutdown (ctx context.Context ) error {
125+ func (bsp * batchSpanProcessor ) Shutdown (ctx context.Context ) error {
129126 var err error
130127 bsp .stopOnce .Do (func () {
131128 wait := make (chan struct {})
@@ -150,7 +147,7 @@ func (bsp *BatchSpanProcessor) Shutdown(ctx context.Context) error {
150147}
151148
152149// ForceFlush exports all ended spans that have not yet been exported.
153- func (bsp * BatchSpanProcessor ) ForceFlush () {
150+ func (bsp * batchSpanProcessor ) ForceFlush () {
154151 bsp .exportSpans ()
155152}
156153
@@ -179,7 +176,7 @@ func WithBlocking() BatchSpanProcessorOption {
179176}
180177
181178// exportSpans is a subroutine of processing and draining the queue.
182- func (bsp * BatchSpanProcessor ) exportSpans () {
179+ func (bsp * batchSpanProcessor ) exportSpans () {
183180 bsp .timer .Reset (bsp .o .BatchTimeout )
184181
185182 bsp .batchMutex .Lock ()
@@ -196,7 +193,7 @@ func (bsp *BatchSpanProcessor) exportSpans() {
196193// processQueue removes spans from the `queue` channel until processor
197194// is shut down. It calls the exporter in batches of up to MaxExportBatchSize
198195// waiting up to BatchTimeout to form a batch.
199- func (bsp * BatchSpanProcessor ) processQueue () {
196+ func (bsp * batchSpanProcessor ) processQueue () {
200197 defer bsp .timer .Stop ()
201198
202199 for {
@@ -222,7 +219,7 @@ func (bsp *BatchSpanProcessor) processQueue() {
222219
223220// drainQueue awaits the any caller that had added to bsp.stopWait
224221// to finish the enqueue, then exports the final batch.
225- func (bsp * BatchSpanProcessor ) drainQueue () {
222+ func (bsp * batchSpanProcessor ) drainQueue () {
226223 for {
227224 select {
228225 case sd := <- bsp .queue :
@@ -245,7 +242,7 @@ func (bsp *BatchSpanProcessor) drainQueue() {
245242 }
246243}
247244
248- func (bsp * BatchSpanProcessor ) enqueue (sd * export.SpanSnapshot ) {
245+ func (bsp * batchSpanProcessor ) enqueue (sd * export.SpanSnapshot ) {
249246 if ! sd .SpanContext .IsSampled () {
250247 return
251248 }
0 commit comments