ML-11: Improve performance of Telemetry.Storage with in-memory buffer

This commit is contained in:
Claudio Ortolina
2026-04-24 10:30:28 +01:00
parent 2a688e2309
commit 252caf31ce
6 changed files with 375 additions and 53 deletions
+6 -1
View File
@@ -205,7 +205,12 @@ checks and post-deploy verification.
### Telemetry
SQLite-backed persistent metrics (`MusicLibraryWeb.Telemetry.Storage`) with 30-second
polling interval. Tracks:
polling interval. Events are buffered in GenServer state keyed by metric and flushed to
SQLite every 5 seconds inside a single transaction; reads via `metrics_history/1`
force-flush only the requested metric so the dashboard sees fresh data without waiting
for the next tick. Per-metric retention is capped at 32 768 rows
(`:retention_limit`), pruned after each flush. Flush failures are logged at `:warning`
and the offending batch is dropped. Tracks:
- Database query times (total, query, queue)
- External API request latency (Finch)