Remove per-player cardinality from websocket Prometheus metrics - #80
Remove per-player cardinality from websocket Prometheus metrics#80cesaregarza wants to merge 1 commit into
Conversation
Review: Remove per-player cardinality from websocket Prometheus metricsOverview: Drops the Code quality
Correctness
Performance
Security
Test coverage
Rollout
Overall: a clean, well-tested, low-risk change that does what it says. The O(P) recompute-on-every-event pattern is the only thing I'd consider tightening, and only if connection churn turns out to be higher than expected in practice. |
Gate verdict — ADVISE-APPROVE ✅ (advise review; BLOCKED on branch protection)Reviewed via a 3-dimension workflow (recording-code correctness/completeness, consumer impact, test honesty). Clean cardinality fix.
Two non-blocking notes:
No blockers. Recommend merge (your call — non-Mandate; also currently BLOCKED, likely needs a review approval / up-to-date branch). |
Motivation
Prometheus does not need SplatTop's per-player aggregation. Using
player_idas a metric label creates an unbounded number of time series and risks substantial Prometheus memory growth when the FastAPI scrape is reconnected.Changes
Remove the
player_idlabel from:fastapi_websocket_connectionsfastapi_websocket_broadcast_duration_secondsfastapi_websocket_bytes_totalfastapi_pubsub_bytes_totalThe connection gauge now reports total active connections, while duration and byte metrics aggregate across players.
Metric names, application-level player routing, payloads, cache behavior, and player logging remain unchanged. Existing aggregate Grafana queries remain compatible.
Validation
git diff --checkpassed.The existing TestClient
/metricstest hangs during app-fixture startup on cleanorigin/main; it was not counted as passing.Rollout dependency
Deploy this application change before reconnecting the Prometheus FastAPI scrape. Otherwise, restoring the scrape against the current application version would recreate high-cardinality per-player series.
Companion GitOps change: GarzAICluster #402
Linear: CES-571