Skip to content

Commit

Permalink
fix goroutine leak in mocktracer
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahkm committed Oct 25, 2024
1 parent 07f6de4 commit 91218a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ddtrace/mocktracer/mocktracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func TestTracerInject(t *testing.T) {

t.Run("ok", func(t *testing.T) {
mt := newMockTracer()
defer mt.Stop()
assert := assert.New(t)

sp := mt.StartSpan("op", tracer.WithSpanID(2))
Expand Down Expand Up @@ -300,6 +301,7 @@ func TestTracerExtract(t *testing.T) {
assert := assert.New(t)

mt := newMockTracer()
defer mt.Stop()
sp := mt.StartSpan("op", tracer.WithSpanID(2))
sp.SetTag(ext.ManualDrop, true)
sp.SetBaggageItem("a", "B")
Expand Down
8 changes: 4 additions & 4 deletions internal/datastreams/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,16 @@ func (p *Processor) flushInput() {
func (p *Processor) run(tick <-chan time.Time) {
for {
select {
case <-p.stop:
// drop in flight payloads on the input channel
p.sendToAgent(p.flush(time.Now().Add(bucketDuration * 10)))
return
case now := <-tick:
p.sendToAgent(p.flush(now))
case done := <-p.flushRequest:
p.flushInput()
p.sendToAgent(p.flush(time.Now().Add(bucketDuration * 10)))
close(done)
case <-p.stop:
// drop in flight payloads on the input channel
p.sendToAgent(p.flush(time.Now().Add(bucketDuration * 10)))
return
default:
s := p.in.pop()
if s == nil {
Expand Down

0 comments on commit 91218a6

Please sign in to comment.