Metrics
Meridian tracks proxy health via compile-time indexed counters, gauges, and histograms. No HashMap lookups on the hot path — metric IDs are usize constants resolved at compile time.
Available Metrics
| Metric | Type | Description |
|---|---|---|
meridian_downstream_cx_total | Counter | Total downstream connections accepted |
meridian_downstream_cx_completed | Counter | Successfully completed connections |
meridian_downstream_cx_failed | Counter | Failed connections (parse errors, upstream failures) |
meridian_downstream_cx_active | Gauge | Currently active downstream connections |
meridian_circuit_breaker_rejected | Counter | Requests rejected by circuit breaker |
meridian_upstream_cx_timeout | Counter | Upstream TCP connect timeouts |
meridian_upstream_cx_error | Counter | Upstream TCP connect errors |
meridian_server_live | Gauge | Server liveness indicator (always 1) |
Architecture
Metrics use IndexedStats<N>, a flat-array stats structure where each metric has a compile-time array index:
counters: [cx_total, cx_completed, cx_failed, cb_rejected, timeout, error, 0, 0]
idx 0 idx 1 idx 2 idx 3 idx 4 idx 5
gauges: [active_connections, 0, 0, 0, 0, 0, 0, 0]
idx 0
histograms: [connect_duration_ms, 0, 0, 0, 0, 0, 0, 0]
idx 0
Counter increment is a single array index + add (~0.5ns). No hashing, no string comparison, no allocation.
Reporting
Metrics are exposed via the admin API’s /stats endpoint in Prometheus text exposition format. See Admin API for details.
Thread Safety
The current implementation uses a Mutex-protected IndexedStats. At the current scale, mutex contention is negligible (recording takes ~0.5ns, lock/unlock ~25ns). For higher scale, the architecture supports per-worker thread-local stats with periodic flush aggregation.