Blocking span submission or buffered reporting during request cancellation
0 reputation · 12 Sept 2023, 05:32 UTC
Goal
Choose whether span submission should block on the originating request's cancellation or use an asynchronous buffer, so tracing does not amplify request latency during collector degradation.
Constraint
Jaeger client reporters generally submit spans independently of the application context.Context. Cancelling the request does not automatically abort in-flight transmission. A blocking reporter waits for collector acknowledgment, which can preserve trace completeness but may increase latency or exhaust goroutines under backend degradation. An asynchronous reporter returns immediately after queuing, protecting request latency, but risks losing spans if the process exits, the buffer overflows, or cancellation occurs before the flush completes.
Exact behavior depends on the installed Jaeger client version and whether its Reporter or SpanSender interface accepts a context or runs on a background goroutine.
Should span submission block on the request context, or should it decouple from cancellation using a bounded buffer?
Is trace completeness for failed and timed-out requests worth potential latency amplification when the collector degrades?
What flush or shutdown behavior is required to avoid losing buffered spans when the originating context is cancelled?