pub struct Metrics { /* private fields */ }Implementations§
Source§impl Metrics
impl Metrics
pub fn new(cr: &Registry, include_path_labels: &Vec<String>) -> Self
Sourcepub fn http_metrics(&self, info: Info<'_>)
pub fn http_metrics(&self, info: Info<'_>)
Get prometheus metrics per-route and how long each route takes.
use prometheus::Registry;
use warp::Filter;
use warp_prometheus::Metrics;
let registry: &Registry = prometheus::default_registry();
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(®istry, &path_includes);
let test_routes = route_one.with(warp::log::custom(move |log| {
metrics.http_metrics(log)
}));
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Metrics
impl !RefUnwindSafe for Metrics
impl Send for Metrics
impl Sync for Metrics
impl Unpin for Metrics
impl !UnwindSafe for Metrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more