Skip to content
This repository was archived by the owner on Aug 17, 2020. It is now read-only.

Commit 8499a17

Browse files
committed
comments
1 parent febc88a commit 8499a17

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

agent/recorder.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (r *SpanRecorder) sendSpans() (error, bool) {
157157

158158
r.logger.Printf("sending %d spans in %d batches", len(spans), batchLength+1)
159159

160-
// Local mutex to synchronize go routines and avoid race conditions
160+
// Local mutex to synchronize go routines and avoid race conditions in lastError var
161161
var lastErrorMutex sync.Mutex
162162
var lastError error
163163
getLastError := func() error {
@@ -194,7 +194,7 @@ func (r *SpanRecorder) sendSpans() (error, bool) {
194194

195195
// We call ingest from a new goroutine
196196
go func(batch []tracer.RawSpan, num, total int) {
197-
defer r.s.Release(1)
197+
defer r.s.Release(1) // We ensure to release the concurrency slot when the go routine finishes
198198

199199
payload := r.getPayload(batch)
200200

@@ -228,12 +228,14 @@ func (r *SpanRecorder) sendSpans() (error, bool) {
228228
atomic.AddInt64(&r.stats.testSpansSent, testSpans)
229229
}
230230
if statusCode == 401 {
231+
// Increment the cancellation flag
231232
atomic.AddInt32(&shouldCancel, 1)
232233
return
233234
}
234235
}(batch, b, batchLength)
235236

236237
}
238+
237239
return lastError, false
238240
}
239241

0 commit comments

Comments
 (0)