Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][processort/tailsamplingprocessor] Limit concurrency for certain tests (flay test on Windows runners) #29014

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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