1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-04-15 11:36:44 +02:00

Move IsSampled check

This commit is contained in:
Vladimir Mihailenco 2020-05-14 14:26:28 +03:00
parent 774889cbfa
commit 8885bc404d

View File

@ -185,11 +185,9 @@ loop:
case <-timer.C: case <-timer.C:
exportSpans() exportSpans()
case sd := <-bsp.queue: case sd := <-bsp.queue:
if sd.SpanContext.IsSampled() { batch = append(batch, sd)
batch = append(batch, sd) if len(batch) == bsp.o.MaxExportBatchSize {
if len(batch) == bsp.o.MaxExportBatchSize { exportSpans()
exportSpans()
}
} }
} }
} }
@ -213,11 +211,9 @@ loop:
return return
} }
if sd.SpanContext.IsSampled() { batch = append(batch, sd)
batch = append(batch, sd) if len(batch) == bsp.o.MaxExportBatchSize {
if len(batch) == bsp.o.MaxExportBatchSize { exportSpans()
exportSpans()
}
} }
case <-timer.C: case <-timer.C:
log.Println("bsp.enqueueWait timeout") log.Println("bsp.enqueueWait timeout")
@ -228,6 +224,10 @@ loop:
} }
func (bsp *BatchSpanProcessor) enqueue(sd *export.SpanData) { func (bsp *BatchSpanProcessor) enqueue(sd *export.SpanData) {
if !sd.SpanContext.IsSampled() {
return
}
bsp.enqueueWait.Add(1) bsp.enqueueWait.Add(1)
select { select {