Skip to content

Commit f144d6a

Browse files
authored
fix(ddtrace/tracer): deflake and fix race in TestEnqueuedTracesHealthMetric (#4097)
Co-authored-by: nick.ripley <[email protected]>
1 parent b41793f commit f144d6a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ddtrace/tracer/metrics_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package tracer
77

88
import (
99
"sync"
10+
"sync/atomic"
1011
"testing"
1112
"time"
1213

@@ -85,13 +86,13 @@ func TestEnqueuedTracesHealthMetric(t *testing.T) {
8586
tracer.StartSpan("operation").Finish()
8687
}
8788
flush(3)
88-
tg.Wait(assert, 1, 10*time.Second)
8989

90-
counts := tg.Counts()
91-
assert.Equal(int64(3), counts["datadog.tracer.queue.enqueued.traces"])
92-
w, ok := tracer.traceWriter.(*agentTraceWriter)
93-
assert.True(ok)
94-
assert.Equal(uint32(0), w.tracesQueued)
90+
assert.Eventually(func() bool {
91+
return tg.Counts()["datadog.tracer.queue.enqueued.traces"] == int64(3)
92+
}, 5*time.Second, 10*time.Millisecond)
93+
94+
w := tracer.traceWriter.(*agentTraceWriter)
95+
assert.Equal(uint32(0), atomic.LoadUint32(&w.tracesQueued))
9596
}
9697

9798
func TestSpansStartedTags(t *testing.T) {

0 commit comments

Comments
 (0)