Skip to main content

Crate dr_metrix_axum

Crate dr_metrix_axum 

Source
Expand description

§metrics-axum

Axum integration for the metrics-exporter workspace.

Provides:

  • PrometheusMetrics — shared state holding the registry, HTTP request metrics, and database collector handles. Drop-in for Axum’s State.
  • HttpMetricsLayer — a Tower layer / middleware that automatically records http_requests_total, http_request_duration_seconds, and http_requests_in_flight for every request.
  • metrics_handler — an Axum handler that encodes and serves the Prometheus text exposition format on GET /metrics.
  • health_handler — a simple GET /health liveness probe.
  • Helpers to register the default Prometheus process collector and an optional Tokio runtime collector so they appear alongside the database metrics.

Re-exports§

pub use handler::health_handler;
pub use handler::metrics_handler;
pub use layer::HttpMetricsLayer;
pub use state::PrometheusMetrics;

Modules§

handler
Axum handlers for /metrics and /health.
http_metrics
layer
Tower Layer + Service that records HTTP metrics for every request.
state
Shared application state that ties the Prometheus registry, HTTP metrics, database collectors, and their background tasks together.