Skip to content

Commit

Permalink
[chore][processort/tailsamplingprocessor] Limit concurrency for certa…
Browse files Browse the repository at this point in the history
…in tests (flay test on Windows runners) (open-telemetry#29014)

**Description:**
Limit number of goroutines started during
`processor/tailsamplingprocessor` tests. This causes very frequently
failures on the Windows tests, see
[here](open-telemetry#28682 (comment))
for example.

The issue is that the race detector has a hard limit on number of
goroutines, see golang/go#23611. The fix
limits the concurrency in two tests so this limit is not hit on GH
Windows runners.

**Link to tracking Issue:** 
Fix open-telemetry#9126

**Testing:**
Increased the concurrency on the two changed tests caused the error and
validated that it passed twice on my fork.

**Documentation:**
N/A
  • Loading branch information
pjanotti authored and jmsnll committed Nov 12, 2023
1 parent 523ff27 commit a937ac3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,17 @@ func concurrencyTest(t *testing.T, numBatches, newBatchesInitialCapacity, batchC

ids := generateSequentialIds(10000)
wg := &sync.WaitGroup{}
// Limit the concurrency here to avoid creating too many goroutines and hit
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/9126
concurrencyLimiter := make(chan struct{}, 128)
defer close(concurrencyLimiter)
for i := 0; i < len(ids); i++ {
wg.Add(1)
concurrencyLimiter <- struct{}{}
go func(id pcommon.TraceID) {
batcher.AddToCurrentBatch(id)
wg.Done()
<-concurrencyLimiter
}(ids[i])
}

Expand Down
8 changes: 8 additions & 0 deletions processor/tailsamplingprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,24 @@ func TestConcurrentTraceArrival(t *testing.T) {
require.NoError(t, tsp.Shutdown(context.Background()))
}()

// Limit the concurrency here to avoid creating too many goroutines and hit
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/9126
concurrencyLimiter := make(chan struct{}, 128)
defer close(concurrencyLimiter)
for _, batch := range batches {
// Add the same traceId twice.
wg.Add(2)
concurrencyLimiter <- struct{}{}
go func(td ptrace.Traces) {
require.NoError(t, tsp.ConsumeTraces(context.Background(), td))
wg.Done()
<-concurrencyLimiter
}(batch)
concurrencyLimiter <- struct{}{}
go func(td ptrace.Traces) {
require.NoError(t, tsp.ConsumeTraces(context.Background(), td))
wg.Done()
<-concurrencyLimiter
}(batch)
}

Expand Down

0 comments on commit a937ac3

Please sign in to comment.