#metrics #warp #registry #filter

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

#1506 in HTTP server

Download history 357/week @ 2024-12-07 247/week @ 2024-12-14 25/week @ 2024-12-21 114/week @ 2024-12-28 294/week @ 2025-01-04 411/week @ 2025-01-11 215/week @ 2025-01-18 334/week @ 2025-01-25 449/week @ 2025-02-01 424/week @ 2025-02-08 260/week @ 2025-02-15 361/week @ 2025-02-22 229/week @ 2025-03-01 724/week @ 2025-03-08 389/week @ 2025-03-15 374/week @ 2025-03-22

1,811 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–21MB
~305K SLoC