Skip to content

Commit d2852e1

Browse files
committed
abstract out prometheus metrics matcher
1 parent 15f4e5b commit d2852e1

File tree

1 file changed

+6
-8
lines changed
  • crates/dscvr-telemetry-util/src

1 file changed

+6
-8
lines changed

crates/dscvr-telemetry-util/src/lib.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
pub use axum::{Matcher, AXUM_HTTP_REQUESTS_DURATION_SECONDS, AXUM_HTTP_REQUESTS_TOTAL};
1+
pub use axum::{AXUM_HTTP_REQUESTS_DURATION_SECONDS, AXUM_HTTP_REQUESTS_TOTAL};
22

33
pub const IC_REPLICA_REQUESTS_TOTAL: &str = "ic-replica-requests-total";
44
pub const IC_REPLICA_REQUESTS_DURATION_SECONDS: &str = "ic-replica-requests-duration-seconds";
55

66
pub mod axum {
77
use axum::{extract::MatchedPath, middleware::Next, response::Response, routing::get, Router};
88
use http::Request;
9-
use metrics_exporter_prometheus::{BuildError, PrometheusBuilder};
9+
use metrics_exporter_prometheus::{BuildError, Matcher, PrometheusBuilder};
1010
use std::time::Instant;
1111

12-
pub use metrics_exporter_prometheus::Matcher;
13-
1412
pub const AXUM_HTTP_REQUESTS_TOTAL: &str = "axum-http-requests-total";
1513
pub const AXUM_HTTP_REQUESTS_DURATION_SECONDS: &str = "axum-http-requests-duration-seconds";
1614

@@ -21,7 +19,7 @@ pub mod axum {
2119
app: Router<S>,
2220
global_buckets: Option<&[f64]>,
2321
global_labels: Option<Vec<(K, V)>>,
24-
matched_metric_buckets: Option<Vec<(Matcher, &[f64])>>,
22+
matched_metric_buckets: Option<Vec<(&str, &[f64])>>,
2523
) -> Result<Router<S>, BuildError>
2624
where
2725
K: Into<String>,
@@ -45,9 +43,9 @@ pub mod axum {
4543
};
4644

4745
let builder = if let Some(buckets) = matched_metric_buckets {
48-
buckets
49-
.into_iter()
50-
.try_fold(builder, |b, (k, v)| b.set_buckets_for_metric(k, v))?
46+
buckets.into_iter().try_fold(builder, |b, (k, v)| {
47+
b.set_buckets_for_metric(Matcher::Full(k.to_owned()), v)
48+
})?
5149
} else {
5250
builder
5351
};

0 commit comments

Comments
 (0)