#prometheus-metrics #warp #afterthought

warp-prometheus

An afterthought of prometheus metrics for Warp

5 releases (breaking)

0.5.0 Oct 18, 2021
0.4.0 Apr 14, 2021
0.3.0 Apr 13, 2021
0.2.0 Apr 13, 2021
0.1.0 Apr 7, 2021

#997 in HTTP server

Download history 211/week @ 2024-04-11 228/week @ 2024-04-18 354/week @ 2024-04-25 147/week @ 2024-05-02 102/week @ 2024-05-09 268/week @ 2024-05-16 214/week @ 2024-05-23 106/week @ 2024-05-30 211/week @ 2024-06-06 206/week @ 2024-06-13 243/week @ 2024-06-20 227/week @ 2024-06-27 169/week @ 2024-07-04 247/week @ 2024-07-11 357/week @ 2024-07-18 374/week @ 2024-07-25

1,206 downloads per month

Apache-2.0

8KB
91 lines

warp-prometheus

Afterthought of Prometheus metrics for Warp Docs Apache-2 licensed CI

Example

use prometheus::Registry;
use warp_prometheus::Metrics;
use warp::Filter;

let registry: Registry = Registry::new();
let path_includes: Vec<String> = vec![String::from("hello")];

let route_one = warp::path("hello")
    .and(warp::path::param())
    .and(warp::header("user-agent"))
    .map(|param: String, agent: String| {
    format!("Hello {}, whose agent is {}", param, agent)
    });

    let metrics = Metrics::new(&registry, &path_includes);

    let test_routes = route_one.with(warp::log::custom(move |log| {
        metrics.http_metrics(log)
    }));

Dependencies

~11–20MB
~288K SLoC