Live state and history
Two questions that look alike and have opposite failure modes. Do not mix them.
Two questions that sound like one:
- What is happening right now? Ask the media plane. It can fail.
- What happened? Read the database. It always answers.
Mixing them produces the worst possible failure: a console that renders "nothing is happening" during the incident it was built to surface.
Live#
GET /public/live asks the control plane, which asks the switchboard. Nothing
is read from the database.
{ "reachable": true, "rooms": [ { "room": "support-8f3a21", "participants": 2 } ] }
{ "reachable": false, "rooms": [], "error": "connect ETIMEDOUT" }
reachable: false is not count: 0, and a console must render them
differently. One says the phones are quiet. The other says you have gone
deaf. Rendering the first when you mean the second is exactly the confusion this
endpoint exists to prevent, and it is why the field is there at all.
The same discipline is inside the tools: get_call_status used to swallow
transport errors and report an unreachable switchboard as a room with nobody in
it. It now raises. A room that genuinely does not exist still answers with an
empty participant list, so only a real transport failure raises.
History#
GET /public/calls and friends read lg_calls. Always answerable, works when
the media plane is down, and covers calls that ended months ago.
Calls API
Why you cannot get "live" from history#
A row is written when a room opens and closed when the media server says it
finished. So ended_at IS NULL means no close event has been processed —
which is also exactly what a lost webhook looks like.
Asking the switchboard is the only answer that cannot be stale. Asking the database is the only answer that cannot be unavailable. You need both, and they are different endpoints on purpose.
The number that is easy to get wrong#
/public/calls/stats reports median latency, and p95 beside it. Not a mean.
A single thirty-second timeout drags a mean far enough to make a good hour look bad, and the resulting alarm trains people to ignore the number — which costs more than the metric was ever worth. The median says what the typical caller actually waited; the p95 says what the unlucky ones did.