Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

MetricTypeDescription
meridian_downstream_cx_totalCounterTotal downstream connections accepted
meridian_downstream_cx_completedCounterSuccessfully completed connections
meridian_downstream_cx_failedCounterFailed connections (parse errors, upstream failures)
meridian_downstream_cx_activeGaugeCurrently active downstream connections
meridian_circuit_breaker_rejectedCounterRequests rejected by circuit breaker
meridian_upstream_cx_timeoutCounterUpstream TCP connect timeouts
meridian_upstream_cx_errorCounterUpstream TCP connect errors
meridian_server_liveGaugeServer 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.