diff options
| author | bndw <ben@bdw.to> | 2026-02-14 12:29:01 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-02-14 12:29:01 -0800 |
| commit | c33395cee66770c4d88a47537c0ed821f6585f62 (patch) | |
| tree | e7f61e5881089f2f10bd06d5828cd7c58b2bc98e /internal | |
| parent | eb666af39feed4be9c8c1354cf52d0ea38ab5d36 (diff) | |
fix: properly chain gRPC interceptors and fix dashboard uptime
Two critical fixes for metrics:
1. Fix interceptor chaining
- Changed from mixed grpc.UnaryInterceptor/ChainUnaryInterceptor to
proper chaining with grpc.ChainUnaryInterceptor
- Metrics interceptor now runs first (as intended)
- All interceptors properly chained in order: metrics → auth → ratelimit
- This fixes metrics not being recorded for any requests
2. Fix dashboard uptime calculation
- Changed from page load time to process_start_time_seconds metric
- Uptime now persists correctly across page refreshes
- Uses Prometheus standard process_start_time_seconds gauge
Before: Metrics showed 0 for all requests, uptime reset on refresh
After: Metrics properly record all gRPC requests, uptime shows actual relay uptime
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/metrics/dashboard.html | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/internal/metrics/dashboard.html b/internal/metrics/dashboard.html index 800b6df..e7af48c 100644 --- a/internal/metrics/dashboard.html +++ b/internal/metrics/dashboard.html | |||
| @@ -189,7 +189,7 @@ | |||
| 189 | </div> | 189 | </div> |
| 190 | 190 | ||
| 191 | <script> | 191 | <script> |
| 192 | let startTime = Date.now(); | 192 | let processStartTime = null; |
| 193 | 193 | ||
| 194 | function parsePrometheusMetrics(text) { | 194 | function parsePrometheusMetrics(text) { |
| 195 | const metrics = {}; | 195 | const metrics = {}; |
| @@ -294,8 +294,15 @@ | |||
| 294 | document.getElementById('event_deletions').textContent = | 294 | document.getElementById('event_deletions').textContent = |
| 295 | sumMetric(metrics, `${prefix}_relay_event_deletions_total`); | 295 | sumMetric(metrics, `${prefix}_relay_event_deletions_total`); |
| 296 | 296 | ||
| 297 | document.getElementById('uptime').textContent = | 297 | const processStart = sumMetric(metrics, 'process_start_time_seconds'); |
| 298 | formatUptime(Date.now() - startTime); | 298 | if (processStart > 0) { |
| 299 | if (!processStartTime) processStartTime = processStart; | ||
| 300 | const uptimeSeconds = Date.now() / 1000 - processStart; | ||
| 301 | document.getElementById('uptime').textContent = | ||
| 302 | formatUptime(uptimeSeconds * 1000); | ||
| 303 | } else { | ||
| 304 | document.getElementById('uptime').textContent = '--'; | ||
| 305 | } | ||
| 299 | 306 | ||
| 300 | document.getElementById('error').innerHTML = ''; | 307 | document.getElementById('error').innerHTML = ''; |
| 301 | } catch (error) { | 308 | } catch (error) { |
| @@ -306,9 +313,6 @@ | |||
| 306 | 313 | ||
| 307 | updateMetrics(); | 314 | updateMetrics(); |
| 308 | setInterval(updateMetrics, 5000); | 315 | setInterval(updateMetrics, 5000); |
| 309 | setInterval(() => { | ||
| 310 | document.getElementById('uptime').textContent = formatUptime(Date.now() - startTime); | ||
| 311 | }, 1000); | ||
| 312 | </script> | 316 | </script> |
| 313 | </body> | 317 | </body> |
| 314 | </html> | 318 | </html> |
