The Batch Exporter: Moving Data Efficiently
Once spans are converted into event envelopes, they must be transmitted to a backend. Sending each event individually would introduce significant overhead. SpanForge uses batching.
Events are queued in memory and flushed based on two thresholds: size and time. By default, a batch is sent when either 512 events accumulate or five seconds elapse.
This reduces network overhead and keeps instrumentation negligible.
Batching introduces backpressure. If the backend slows—for example, from 50 ms to 500 ms per batch—the queue begins to fill. As it approaches seventy percent capacity, flush frequency increases and warnings are emitted. At ninety percent, the exporter applies an overflow policy, typically dropping new events until capacity stabilizes.
If the backend becomes unavailable, a circuit breaker halts export attempts temporarily. This prevents repeated failures from affecting application performance.
Observability remains non-intrusive, even under stress.