Repository navigation
feat(mqtt): emit an always-on broker uptime gauge for liveness - #14188
Conversation
Every broker metric is a synchronous counter or histogram, recorded only when a client acts (CONNECT, packet, subscription). So a freshly rolled worker in a quiet region exports nothing until the first client connects, which can be many minutes. A metrics dead-man cannot tell that apart from the broker being down, and pages on healthy rollouts. Register an observable gauge mqtt.server.uptime, observed on every telemetry collect from onWorkerStart. It reports within one cycle of a worker starting regardless of traffic, and resets to zero on restart. This mirrors how realtime keeps realtime.server.active_workers off the request path. The broker-not-reporting alert will anchor on this series. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Review complete. No issues found — approved ✅. The change registers an observable uptime gauge in
One lower-confidence observation (kept at summary level): the collect tick callback calls Reviewed commit: c2ce13d |
🟢 Tier S · Ready to merge
Adds an observable Latest changes: The latest commit passes an explicit empty attributes array to the uptime observer.
📂 Walkthrough · 1
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
PHPStan reads the observer callable as (float|int $value, iterable $attributes): void with both required, so observing with one argument failed arguments.count. Pass an empty attributes array explicitly. Co-Authored-By: Claude Opus 4.8 <[email protected]>
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Why
The MQTT broker-not-reporting liveness alert pages on healthy brokers after a rollout.
Every broker metric is a synchronous instrument (
mqtt.connections.opened,mqtt.connections.active,mqtt.packets.received,mqtt.subscriptions, the adapter'smqtt.messages.*/ histograms). OpenTelemetry exports no series for a synchronous instrument until its firstadd()/record()— i.e. until a client does something. A rollout restarts the broker and resets the meter, so in a quiet region (e.g.tor1) the fresh pods export nothing until the first CONNECT, which can exceed the alert's 15-minute window. The dead-man can't tell that from the broker being down, so it fires on a healthy rollout.Change
Register an observable gauge
mqtt.server.uptime(seconds) inonWorkerStart, observed on every telemetrycollect():Because it's observed on the collect tick (not on a client action), the broker reports within one cycle of a worker starting, regardless of traffic, and the value resets to zero on restart. This mirrors how
app/realtime.phpkeepsrealtime.server.active_workersoff the request path. There's noonWorkerStopon the broker adapter, so a gauge (which simply stops being observed when the worker dies) is the right shape rather than an up/down counter.Follow-up
The monitoring repo's
mqtt-broker-not-reportingdead-man will be re-anchored frommqtt_connections_opened_totaltomqtt_server_uptime_secondsand restored tocriticalonce this ships. (It was temporarily downgraded towarningto stop the false pages.)🤖 Generated with Claude Code