From 8885bc404d4752340785dbe60cc3bc2883f84554 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Thu, 14 May 2020 14:26:28 +0300 Subject: [PATCH] Move IsSampled check --- sdk/trace/batch_span_processor.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sdk/trace/batch_span_processor.go b/sdk/trace/batch_span_processor.go index 4b320eb4d..bde8aef2b 100644 --- a/sdk/trace/batch_span_processor.go +++ b/sdk/trace/batch_span_processor.go @@ -185,11 +185,9 @@ loop: case <-timer.C: exportSpans() case sd := <-bsp.queue: - if sd.SpanContext.IsSampled() { - batch = append(batch, sd) - if len(batch) == bsp.o.MaxExportBatchSize { - exportSpans() - } + batch = append(batch, sd) + if len(batch) == bsp.o.MaxExportBatchSize { + exportSpans() } } } @@ -213,11 +211,9 @@ loop: return } - if sd.SpanContext.IsSampled() { - batch = append(batch, sd) - if len(batch) == bsp.o.MaxExportBatchSize { - exportSpans() - } + batch = append(batch, sd) + if len(batch) == bsp.o.MaxExportBatchSize { + exportSpans() } case <-timer.C: log.Println("bsp.enqueueWait timeout") @@ -228,6 +224,10 @@ loop: } func (bsp *BatchSpanProcessor) enqueue(sd *export.SpanData) { + if !sd.SpanContext.IsSampled() { + return + } + bsp.enqueueWait.Add(1) select {