mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-03-05 15:05:51 +02:00
Fix timer.Stop
This commit is contained in:
parent
28571207b7
commit
b2285e0c71
@ -166,9 +166,6 @@ func (bsp *BatchSpanProcessor) processQueue() {
|
|||||||
batch := make([]*export.SpanData, 0, bsp.o.MaxExportBatchSize)
|
batch := make([]*export.SpanData, 0, bsp.o.MaxExportBatchSize)
|
||||||
|
|
||||||
exportSpans := func() {
|
exportSpans := func() {
|
||||||
if !timer.Stop() {
|
|
||||||
<-timer.C
|
|
||||||
}
|
|
||||||
timer.Reset(bsp.o.ScheduledDelayMillis)
|
timer.Reset(bsp.o.ScheduledDelayMillis)
|
||||||
|
|
||||||
if len(batch) > 0 {
|
if len(batch) > 0 {
|
||||||
@ -187,6 +184,9 @@ loop:
|
|||||||
case sd := <-bsp.queue:
|
case sd := <-bsp.queue:
|
||||||
batch = append(batch, sd)
|
batch = append(batch, sd)
|
||||||
if len(batch) == bsp.o.MaxExportBatchSize {
|
if len(batch) == bsp.o.MaxExportBatchSize {
|
||||||
|
if !timer.Stop() {
|
||||||
|
<-timer.C
|
||||||
|
}
|
||||||
exportSpans()
|
exportSpans()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,6 +201,7 @@ loop:
|
|||||||
if !timer.Stop() {
|
if !timer.Stop() {
|
||||||
<-timer.C
|
<-timer.C
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is not needed normally, but use some timeout so we are not stuck
|
// This is not needed normally, but use some timeout so we are not stuck
|
||||||
// waiting for enqueueWait forever.
|
// waiting for enqueueWait forever.
|
||||||
const waitTimeout = 30 * time.Second
|
const waitTimeout = 30 * time.Second
|
||||||
@ -208,7 +209,7 @@ loop:
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case sd := <-bsp.queue:
|
case sd := <-bsp.queue:
|
||||||
if sd == nil {
|
if sd == nil { // queue is closed
|
||||||
exportSpans()
|
exportSpans()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user