CAPTURE_QUEUE_CAPACITY

const val CAPTURE_QUEUE_CAPACITY: Int = 1024

How deep the capture queue is — the buffer between the application's synchronous logging call and the drain coroutine that exports each event.

The queue exists because the app's log() call cannot suspend, so the drain runs behind it. When the drain falls behind, this is the number of events held before the oldest start being dropped (and counted on CaptureHealth.droppedEvents).

Why this number

It is chosen from three independent bounds that happen to agree:

  • Burst. An app's noisiest moments — startup, a reconnect storm, an exception cascade — are a few hundred lines over a second or two. A depth below that would drop events while the drain is merely momentarily behind, which is the case the queue is for.

  • Heap. A queued NormalizedLogEvent is a level, two strings and — after LogCapture.resolveAtEdgetwo attribute maps (NormalizedLogEvent.attributes and its resolved copy), so call it a couple of kilobytes rather than one. This depth therefore bounds the queue's contribution to the host application's heap in the low single-digit megabytes, and only when the drain is fully stalled; a keeping-up drain holds nothing. That is about the largest fixed worst case worth imposing on a mobile host for a diagnostics subsystem.

  • Staleness. At the field's measured worst case — a Debug build on an A12 against a large store, 692–1153 ms per export (#1860) — a full queue is already 12–20 minutes of backlog. Records that old have lost their relation to whatever is being diagnosed, so a deeper queue buys staleness rather than fidelity.

Why it is not tunable

A knob here would invite raising the depth in response to sustained loss, and sustained loss is not a depth problem: the drain is slower than the producer, so a bigger queue only defers the same drops while holding more heap. The response that works is a cheaper export path. CaptureHealth.droppedEvents makes the loss visible so that conversation can start; the queue depth stays fixed so it cannot be used to hide it. (A depth parameter can be added later without breaking anything; a shipped one cannot be taken away.)