diff options
| author | bndw <ben@bdw.to> | 2026-02-14 12:53:50 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-14 12:53:50 -0800 |
| commit | 75fb3a583cf4e8a7ca34bedb3322d309bb170ed4 (patch) | |
| tree | 175a9cd032779ee4f448a2fa931eeaef0c0f283a /internal/metrics | |
| parent | 40df56985402a31695a9a3bb13319bd2a3276305 (diff) | |
feat: add storage stats and average latency metrics
Track and display storage and performance metrics that were previously
showing zeros.
Storage metrics:
- Add GetStats() method to storage returning event count and DB size
- Store database file path for size calculation
- Update metrics every 30 seconds via goroutine in main.go
- Display event count and DB size (MB) in dashboard
Performance metrics:
- Calculate average latency from histogram sum/count metrics
- Display as milliseconds in dashboard
- Formula: (duration_sum / duration_count) * 1000
Missing metrics (deferred):
- Connections: requires connection lifecycle tracking (gRPC + WebSocket)
- Deletions: count would need API change to ProcessDeletion
Dashboard now shows accurate storage stats and request latency!
Diffstat (limited to 'internal/metrics')
| -rw-r--r-- | internal/metrics/dashboard.html | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/metrics/dashboard.html b/internal/metrics/dashboard.html index 363f1f7..63b42ed 100644 --- a/internal/metrics/dashboard.html +++ b/internal/metrics/dashboard.html | |||
| @@ -295,6 +295,12 @@ | |||
| 295 | document.getElementById('event_deletions').textContent = | 295 | document.getElementById('event_deletions').textContent = |
| 296 | sumMetric(metrics, `${prefix}_relay_event_deletions_total`); | 296 | sumMetric(metrics, `${prefix}_relay_event_deletions_total`); |
| 297 | 297 | ||
| 298 | const durationSum = sumMetric(metrics, `${prefix}_relay_request_duration_seconds_sum`); | ||
| 299 | const durationCount = sumMetric(metrics, `${prefix}_relay_request_duration_seconds_count`); | ||
| 300 | const avgLatencyMs = durationCount > 0 ? (durationSum / durationCount * 1000) : 0; | ||
| 301 | document.getElementById('avg_latency').innerHTML = | ||
| 302 | `${avgLatencyMs.toFixed(1)}<span class="metric-unit">ms</span>`; | ||
| 303 | |||
| 298 | const processStart = sumMetric(metrics, 'process_start_time_seconds'); | 304 | const processStart = sumMetric(metrics, 'process_start_time_seconds'); |
| 299 | if (processStart > 0) { | 305 | if (processStart > 0) { |
| 300 | if (!processStartTime) processStartTime = processStart; | 306 | if (!processStartTime) processStartTime = processStart; |
