Skip to content

Commit fa1e3f5

Browse files
committed
Document how telemetry batches and sheds events on the wire
1 parent e0edf94 commit fa1e3f5

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/TELEMETRY.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,27 @@ Events are sent to PostHog. PostHog derives an approximate country from the
9292
request IP server-side; the client sends no location data itself. No
9393
self-hosted or third-party analytics beyond PostHog are used.
9494

95+
## On the wire
96+
97+
Events are not sent one at a time. Each captured event is stamped with its
98+
capture time and held in an in-memory queue, which is posted to PostHog's
99+
`/batch/` endpoint when it reaches the batch size or when the batch
100+
interval elapses, whichever comes first. At most one request is ever in
101+
flight: events captured while a request is open wait for it rather than
102+
opening another connection. Exit paths flush the queue, bounded by a short
103+
deadline so a slow endpoint cannot delay quitting.
104+
105+
The queue has a hard depth limit. Once it is full — which in practice means
106+
the endpoint is unreachable, as on a captive portal or behind a hung proxy
107+
— the oldest queued events are dropped to make room for new ones. Telemetry
108+
is therefore lossy by design: it never grows memory without bound, never
109+
retries indefinitely, and never blocks or reports failures to the user.
110+
Nothing is written to disk, so dropped events are gone rather than deferred
111+
to a later run.
112+
113+
See `src/telemetry/index.ts` for the batch size, interval, and queue limit
114+
in force.
115+
95116
## Not this document
96117

97118
Local performance tracing and optional OpenTelemetry export to an operator-owned

0 commit comments

Comments
 (0)