#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

#923 in HTTP server

Download history 223/week @ 2023-12-07 137/week @ 2023-12-14 144/week @ 2023-12-21 146/week @ 2023-12-28 208/week @ 2024-01-04 134/week @ 2024-01-11 200/week @ 2024-01-18 124/week @ 2024-01-25 132/week @ 2024-02-01 118/week @ 2024-02-08 155/week @ 2024-02-15 172/week @ 2024-02-22 140/week @ 2024-02-29 173/week @ 2024-03-07 185/week @ 2024-03-14 165/week @ 2024-03-21

715 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–22MB
~300K SLoC