Proposed Proposal #00794praxis
Expand Prometheus Metrics Surface
Praxis currently exposes two Prometheus metrics on the admin /metrics endpoint: praxis_http_requests_total (counter) and praxis_http_request_duration_seconds (histogram).
What?
Praxis currently exposes two Prometheus metrics on the admin
/metrics endpoint: praxis_http_requests_total (counter) and
praxis_http_request_duration_seconds (histogram). That surface is
insufficient for production diagnostics.
This proposal expands /metrics with the families below so
operators can observe payload size, connection load, upstream
connect behavior, retries, circuit-breaker and load-balancer
edge cases, cluster health, and config reload lifecycle. The
first cut prioritizes signals that map to behavior Praxis already
runs and that stay bounded in cardinality; additional series can
follow once this baseline is in place. All metrics continue to
use the existing metrics crate facade and
metrics-exporter-prometheus backend.
Scope follows #794 and the review discussion on that issue / this proposal.
Existing series improvement
- Populate the existing
routelabel onpraxis_http_requests_totalandpraxis_http_request_duration_secondswhen a real route is known (today it is often hard-codedunknown). This does not add a new family; it improves the usefulness of the current scrape. Label stays a bounded route id (routerpath_match), never a raw request path.
Proposed metrics
Request/response sizing:
praxis_http_request_body_bytes(histogram; labels:method,status_class,cluster)praxis_http_response_body_bytes(histogram; labels:method,status_class,cluster)
Connection state and shedding:
praxis_connections_active(gauge; label:listener) — concurrent connections per listener, covering HTTP and TCPpraxis_overload_rejects_total(counter; labels:reason=memory|global_connections|listener_connections) — load already shed via existing memory/connection limits (today visible mainly as 503 / closed connections in logs)
Upstream performance:
praxis_upstream_connect_duration_seconds(histogram; label:cluster) — time to establish an upstream connectionpraxis_upstream_connect_failures_total(counter; label:cluster) — upstream connect failures (detailedreasonlabels can be considered in a later iteration if the reason set stays small and stable)
Upstream connect retries (existing behavior: idempotent-request connect-failure retries only—not response/status retries):
praxis_upstream_retries_total(counter; labels:cluster,result=success|exhausted) —success= connect eventually succeeded after at least one retry;exhausted= retries gave up or were skipped by policy
Circuit breaker (existing HTTP filter, currently invisible on
/metrics):
praxis_circuit_breaker_open(gauge; label:cluster) —1when open/half-open,0when closed (a trip counter is an acceptable alternative if simpler)
Load balancing panic path (existing warn when all endpoints are unhealthy but traffic is still selected):
praxis_lb_panic_mode_total(counter; label:cluster) — HTTP and TCP load balancers
Health (cluster aggregates on the default scrape surface, rather than per-endpoint gauges; covers active and passive health already present in runtime):
praxis_upstream_healthy_endpoints(gauge; label:cluster)praxis_upstream_total_endpoints(gauge; label:cluster)praxis_upstream_health_transitions_total(counter; labels:cluster,result=healthy|unhealthy) — flapping / transition visibility
Config reload:
praxis_config_reload_total(counter; labels:result=success|failure)praxis_config_reload_last_success_timestamp(gauge)
Goals
- Emit the metrics listed above on admin
/metrics - Prefer low-cardinality label sets by default; avoid per-endpoint health fan-out on the primary scrape path
- Follow existing label conventions (
method,status_class,cluster) where they apply - Cover the new series with unit tests and a scrape-based integration test
- Avoid measurable latency or memory regression from the added instrumentation
- Prefer opt-in metric families when that fits cleanly (extend
the existing
MetricsConfigpattern used byfilter_durationwhen adding heavier follow-ups)
Non-Goals
- Delivering a comprehensive proxy-wide stats catalog in this change
- High-cardinality defaults (for example per-endpoint health as the primary health signal; per-endpoint detail remains available via existing readiness/verbose admin views where present)
- Changing the meaning of existing HTTP request count/duration
metrics or the per-filter duration metric from
#9
(
praxis_filter_duration_seconds) - Building
praxis_filter_rejections_totalin this change (useful for support; natural follow-up) - Timeout-filter exceeded counters, TLS certificate-reload counters, callout/ext-proc breaker series, and typed timeout taxonomies in this change
- Broader TCP byte/duration catalogs under #8 beyond the connection and failure signals above
- Response-level / status-code upstream retries (Praxis does not implement those today)
Why?
Motivation
With only request count and duration, operators cannot see payload
size, concurrent load, whether the proxy is shedding overload,
whether connect retries are masking upstream pain, whether a
circuit breaker or LB panic path is in play, whether a cluster is
degraded, or whether config reloads are succeeding. Those
questions come up in incidents today, but answers live in logs
rather than /metrics.
This change focuses on operationally actionable series that reflect runtime behavior Praxis already has, while keeping default scrape cardinality and instrumentation cost under control. Finer-grained or broader families can be added later once this baseline is proven. Overly fine label dimensions have a real memory and performance cost in production scrapes.
Exposing these metrics on the existing /metrics endpoint keeps
operators on one Prometheus-compatible path without introducing a
second telemetry pipeline.
Related context for response body sizing:
#383
(closed) fixed access_log reporting response_body_bytes=0
when no response-body filter was configured. Histogram emission
for response sizes must reflect accurate byte counts.
User Stories
These are stakeholder needs derived from #794 and the proposal review discussion; they are not separate tracked issues.
- As an SRE, I want cluster-level healthy/total endpoint gauges and health transition counters so that I can tell if a cluster is degraded or flapping without a per-host series explosion.
- As an SRE, I want connect-retry and circuit-breaker series so that I can separate “upstream connect is failing” from “we are recovering via connect retries” or “the breaker is open.”
- As an SRE, I want overload-reject and LB panic-mode counters so that I can see shedding and “all unhealthy but still routing” without grepping logs.
- As an SRE, I want request/response body size histograms so that payload growth is visible before it drives timeouts, memory pressure, or network saturation.
- As a platform operator, I want config reload success/failure counters and a last-success timestamp so that failed or stalled reloads show up in monitoring, not only in process logs.
- As a platform operator, I want active-connection gauges for HTTP and TCP listeners so that I can plan capacity and detect uneven load or connection leaks.
- As a platform operator, I want upstream connect-failure visibility so that non-performing clusters can be identified for recovery actions.
Decisions
Record of answers that close the earlier open questions from review of this proposal and runtime fit.
- HTTP and TCP:
praxis_connections_activecovers both. - Failures: include upstream connect-failure visibility so non-performing clusters can drive recovery actions.
- Gating: emit the families in this proposal when the
Prometheus recorder is installed for admin
/metrics. Per-familyMetricsConfigflags (likefilter_duration) remain a follow-up for heavier optional series. - Labels: body-size histograms use
method,status_class,cluster; connect, retry, breaker, health, and panic series usecluster; active connections uselistener; overload rejects use a small fixedreasonset; follow existing conventions elsewhere. - Health shape: cluster
healthy/totalendpoint gauges plus transition counters on the default scrape (per-endpoint detail stays on readiness/verbose admin views). Health signals reflect live status including existing passive-health behavior. - Connect failure
reason: leave for a later iteration; cluster-only counter is sufficient here. - Uptime gauge: leave for later;
/healthyand/readyalready cover process liveness for now. - Scope discipline: prefer actionable diagnostics with bounded cardinality in this change; broader catalogs can follow.
routelabel shape: Exact path matches emit the bare path; Prefix matches append*(for example/api/v1vs/api/v1*) so identical path strings of different match kinds stay distinguishable without a second label dimension.connections_activesemantics: under HTTP keep-alive the gauge tracks in-flight requests (one guard per request context), not raw TCP sockets; for TCP it tracks open proxy sessions. Grouped TCP listeners resolve thelistenerlabel from the connection’s local bind address.
How?
Implementation
- #825 (open draft) — baseline metric families, route-label population, scrape integration coverage, and reload safety for health / circuit-breaker gauges
Design
The design below matches the code in #825 (not yet merged).
Instrumentation stays on the existing metrics facade and
admin /metrics scrape path (metrics-exporter-prometheus).
Families emit only when the Prometheus recorder is installed
(admin address configured); there is no second telemetry pipeline.
Recording sites (existing runtime paths):
- HTTP request completion → request count/duration + body-size
histograms (
protocolPingora handler) - Overload shedding and
ActiveConnectionGuard→praxis_overload_rejects_total/praxis_connections_active(HTTP handler + TCP proxy) - Upstream connect timing / failures / connect-failure retries → connect-duration histogram plus failure/retry counters (handler / upstream peer)
- Circuit breaker state transitions +
Dropon pipeline swap →praxis_circuit_breaker_open(filtercircuit breaker) - HTTP/TCP load-balancer “all unhealthy” path →
praxis_lb_panic_mode_total - Active and passive health updates → healthy/total gauges and
transition counters; reload clears stale cluster gauges and
re-seeds from the new registry (
serverreload + health runner) - Config watcher → reload success/failure counter and last-success timestamp
Bounded route label: only the router filter sets
metrics_route today. It precomputes a SharedString per
configured route at construction (Exact → bare path,
Prefix → path*) and clones it into request context on match.
The raw request URL is never used as a label. Unmatched traffic
(and pipelines without router, including
iterative_request_router) keep route="unknown".
Route-label support for iterative_request_router is an
intentional follow-up, not part of #825.
Cardinality and cost: prefer cluster / listener / small fixed
enums over per-endpoint series on the default scrape. Cheap
SharedString clones (often via Arc) on hot paths; construction-
time allocations for static route labels. Opt-in
metrics.filter_duration remains the pattern for heavier optional
families; the #794 pack itself is on whenever /metrics is live.
Tests: unit coverage for record helpers, route Exact/Prefix
labels, TCP listener-label resolution, and panic-mode emission;
integration suite
tests/integration/tests/suite/prometheus_metrics.rs scrapes
admin /metrics for happy-path labels, overload rejects, retries,
circuit-breaker open/recovery/Drop-on-reload, health gauges,
HTTP+TCP panic mode, and config reload.
Explicitly out of this How (see Non-Goals / Decisions):
connect-failure reason taxonomy, praxis_filter_rejections_total,
uptime gauge, per-endpoint health on the default scrape, broader
TCP catalogs under #8, and route labels from
iterative_request_router.