You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-27 22:49:15 +02:00
sdk/trace: Fix gorountine leak in batchSpanProcessor.ForceFlush (#6369)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/6360 Per https://github.com/open-telemetry/opentelemetry-go/issues/6360#issuecomment-2678080742: > So I'd fix this issue with the first proposed solution, and open an issue to change the behavior in a separate PR. ``` $ go test -run=TestBatchSpanProcessorForceFlushTimeout -count=1000 PASS ok go.opentelemetry.io/otel/sdk/trace 1.701s $ go test -run=TestBatchSpanProcessorForceFlushTimeout -count=1000 -race PASS ok go.opentelemetry.io/otel/sdk/trace 4.056s ``` @peterbourgon, thank you for your contribution 🏅
This commit is contained in:
@@ -201,10 +201,9 @@ func (bsp *batchSpanProcessor) ForceFlush(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
wait := make(chan error)
|
||||
wait := make(chan error, 1)
|
||||
go func() {
|
||||
wait <- bsp.exportSpans(ctx)
|
||||
close(wait)
|
||||
}()
|
||||
// Wait until the export is finished or the context is cancelled/timed out
|
||||
select {
|
||||
|
||||
Reference in New Issue
Block a user