Function tide_prometheus::metrics_endpoint[][src]

pub async fn metrics_endpoint<State>(_request: Request<State>) -> Result
Expand description

A convencience tide::Endpoint that gathers the metrics with prometheus::gather and then returns them inside the response body as specified by the Prometheus docs.

Example

let mut server = tide::new();
server.with(tide_prometheus::Prometheus::new("tide"));
server.at("/metrics").get(tide_prometheus::metrics_endpoint);

Note that serving the metrics on the same server they’re counted on will make Prometheus’s scraping also get counted in them. If you want to avoid this you can use something like tide-fluent-routes and have separate trees for your main routes and the one for the metrics endpoint. Or you can just run a completely separate server in the same program.