Expand description
Lightweight WS message-throughput instrumentation.
Counts inbound (client → server) and outbound (server → client) WS messages
per kind into atomic counters, and a single dedicated thread emits a
summary log line every WINDOW_MS. No per-message log I/O, no allocations
on the hot path, no work when no messages flowed.
Used to diagnose “server CPU is idle but loads are slow” — comparing the inbound and outbound rates against the client-side equivalents tells us whether time is in server-reply latency, client-send pacing, or round-trip.
Functions§
- message_
kind - Stable
'statickind tag for a message. Must match what the TS client emits for symmetric cross-side correlation. - message_
tag - The specific command/query/report/view id carried by a message, when the
wire type carries one directly.
*Requestand*Errorvariants carry their id inline;*Response/*Cancel/*Windowvariants only carrytx(the id lives in a tx→id side table the caller already tracks per subscription) — those returnNonehere rather than duplicating that lookup. - record_
inbound - Record an inbound WS message (already parsed).
kindshould be the'staticdiscriminant string frommessage_kind. - record_
inbound_ for_ client - Same as
record_inbound, plus an OTLP counter tagged byclient_idandtag(the specific command/query/report/view id, frommessage_tag, when the message carries one) — the aggregateDashMapcounters above are cheap enough for an unbounded number of message kinds, but tagging those by client_id/tag too would put an OTel series per (kind × client × tag) into the periodic in-process log line, which is the wrong place for this breakdown. This is that breakdown, exported as a proper metric instead (cardinality bounded by concurrent connections × distinct command/query/report/view ids, which is the norm for these tags). - record_
outbound - Record an outbound WS message about to be serialized to the wire.
- record_
outbound_ for_ client - Same as
record_outbound, plus a per-client/per-tag OTLP counter — seerecord_inbound_for_client. - start_
periodic_ logger - Spawn the dedicated summary thread. Idempotent — safe to call from any
number of
CellServerCtx::newinvocations.