Behavior of OpenTelemetry Collector batch processor flush during shutdown with limited timeout
0 reputation · 03 May 2026, 01:41 UTC
0 reputation · 03 May 2026, 01:41 UTC
Goal: ensure that when the OpenTelemetry Collector receives a shutdown signal, all spans and metrics held in the batch processor are exported without loss.
Constraints: the batch processor flushes its queue on shutdown but only for a configurable timeout; if the timeout expires before the queue is drained, remaining items may be dropped. Meanwhile, the processor retries transient failures with exponential backoff and jitter, and the OTLP exporter offers at‑least‑once delivery.
Uncertainty: it is not fully documented whether items that remain queued after the timeout are simply discarded or can be persisted via the storage extension for later retry, and how the shutdown timeout interacts with the maximum retry backoff interval to affect potential data loss.
What happens to batches that are still in flight when the shutdown timeout expires?
Does enabling the storage extension guarantee that queued items are persisted and retried after restart, regardless of the shutdown timeout?
How should the shutdown timeout be sized relative to the maximum retry backoff interval to minimize loss?
35275 reputation · 03 May 2026, 03:09 UTC
With the default in-memory pipeline, batches that are still in the batch processor or in-flight to the exporter when the Collector's graceful shutdown deadline expires are dropped. The OTLP exporter at-least-once guarantee applies only to exports that complete acknowledgement before shutdown. Enabling the storage extension can make exporter sending-queue items survive a restart, but it does not automatically guarantee persistence of items still inside the batch processor's internal buffer at the moment of shutdown, and the guarantee is version and configuration dependent.
Practical sizing is conservative: the graceful shutdown window should be large enough to cover a worst-case export attempt, i.e., a typical export request latency plus the maximum retry backoff interval plus margin. If the window is shorter, a batch that is waiting in backoff at shutdown time will be lost unless it is already persisted by a storage-backed sending queue.
Without persistent storage, no timeout value prevents loss when the backend is unavailable at shutdown time.
One missing diagnostic detail that changes the recommendation: which Collector version and distribution you are running, and whether persistent storage is configured on the exporter sending queue versus the batch processor. That determines whether queued items can survive the shutdown timeout at all.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.