From 94901e0fe798d0fb38b9e6d122376c15264ca46a Mon Sep 17 00:00:00 2001 From: dayvejones <75860773+dayvejones@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:25:31 +0300 Subject: [PATCH] Update axum prometheus-metrics example (#2516) Co-authored-by: Dudin.Roman --- examples/prometheus-metrics/Cargo.toml | 4 ++-- examples/prometheus-metrics/src/main.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/prometheus-metrics/Cargo.toml b/examples/prometheus-metrics/Cargo.toml index c29993de..a30e4436 100644 --- a/examples/prometheus-metrics/Cargo.toml +++ b/examples/prometheus-metrics/Cargo.toml @@ -6,8 +6,8 @@ publish = false [dependencies] axum = { path = "../../axum" } -metrics = "0.18" -metrics-exporter-prometheus = "0.8" +metrics = { version = "0.22", default-features = false } +metrics-exporter-prometheus = { version = "0.13", default-features = false } tokio = { version = "1.0", features = ["full"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/examples/prometheus-metrics/src/main.rs b/examples/prometheus-metrics/src/main.rs index 1944317c..0a1b2108 100644 --- a/examples/prometheus-metrics/src/main.rs +++ b/examples/prometheus-metrics/src/main.rs @@ -110,8 +110,8 @@ async fn track_metrics(req: Request, next: Next) -> impl IntoResponse { ("status", status), ]; - metrics::increment_counter!("http_requests_total", &labels); - metrics::histogram!("http_requests_duration_seconds", latency, &labels); + metrics::counter!("http_requests_total", &labels).increment(1); + metrics::histogram!("http_requests_duration_seconds", &labels).record(latency); response }