Skip to content
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