Priority
Medium-high — runtime availability under load and predictable observability overhead.
Context
runtime/trace/span.go exports a completed span by starting a new goroutine for every span:
func recordSpanAsync(tracer *Tracer, sink Sink, snapshot Snapshot) {
go func() {
ctx, cancel := context.WithTimeout(context.Background(), defaultSinkTimeout)
defer cancel()
_ = sink.RecordSpan(ctx, snapshot)
...
}()
}
Each goroutine has a timeout, but there is no global queue size, concurrency limit, or drop/backpressure policy around sink export.
Problem
A slow or stuck sink can cause unbounded goroutine growth when many spans complete.
Consequences:
- High request volume can create many concurrent export goroutines.
- A slow sink can consume memory and scheduler resources even though each individual export eventually times out.
- Runtime overhead becomes hard to reason about for generated applications.
- There is no explicit dropped-span counter or health signal for export backpressure.
- Tests may cover sink timeout behavior but not sustained high-throughput pressure.
Proposed direction
Move span export behind a bounded worker/queue owned by the tracer.
Suggested behavior:
- fixed maximum queue length;
- fixed maximum concurrent sink exports;
- configurable or documented drop policy when full;
- counters for exported, failed, timed out, and dropped spans;
- graceful shutdown/drain hook where useful;
- synchronous fallback only for tests, if needed.
Acceptance criteria
Related
Priority
Medium-high — runtime availability under load and predictable observability overhead.
Context
runtime/trace/span.goexports a completed span by starting a new goroutine for every span:Each goroutine has a timeout, but there is no global queue size, concurrency limit, or drop/backpressure policy around sink export.
Problem
A slow or stuck sink can cause unbounded goroutine growth when many spans complete.
Consequences:
Proposed direction
Move span export behind a bounded worker/queue owned by the tracer.
Suggested behavior:
Acceptance criteria
Related