Expand description
Server-wide and per-route Prometheus metrics.
Server-wide counters (REQUESTS_TOTAL, ERRORS_TOTAL,
ACTIVE_CONNECTIONS) are updated by the server core automatically.
Per-route metrics are opt-in: wrap your application with
MetricsLayer and each request will be attributed to its
(method, path) pair, emitting:
rws_route_requests_total{method,path,status}— request countsrws_route_duration_seconds{method,path}— latency histogram
§Example
use rust_web_server::app::App;
use rust_web_server::core::New;
use rust_web_server::metrics::MetricsLayer;
let app = App::new().wrap(MetricsLayer);Structs§
- Metrics
Layer - Middleware that records per-route request counts and latency histograms.
Statics§
- ACTIVE_
CONNECTIONS - Number of currently open TCP/QUIC connections.
- ERRORS_
TOTAL - Requests that caused an application-level error (app.execute returned Err).
- REQUESTS_
TOTAL - Total HTTP requests handled across all connections and protocols.
- SERVER_
READY - Set to
trueaftercrate::server::Server::setupcompletes. The/readyzcontroller returns503until this istrue. Set back tofalsewhen a shutdown signal is received so that Kubernetes stops routing traffic before the pod exits.
Functions§
- connection_
close - connection_
open - prometheus_
text - Returns a Prometheus text-format snapshot of all server-wide and per-route metrics.
- record_
error - record_
request - record_
route - Record a completed request in the per-route store.