From 7398888ce269abe305c4cd578df8cc17e81e4d61 Mon Sep 17 00:00:00 2001 From: tyranron Date: Mon, 21 Oct 2024 12:44:47 +0200 Subject: [PATCH] Upgrade `metrics` crate from 0.23 to 0.24 version --- CHANGELOG.md | 7 +++++-- Cargo.toml | 6 +++--- src/metric.rs | 14 ++++++++++++++ src/recorder/mod.rs | 14 ++++++++------ 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd445f6..f22b5a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,11 @@ All user visible changes to this project will be documented in this file. This p ### BC Breaks -- Bumped up [MSRV] to 1.81 because for `#[expect]` attribute usage. ([todo]) +- Upgraded to 0.24 version of `metrics` crate. ([todo]) +- Upgraded to 0.18 version of `metrics-util` crate. ([todo]) +- Bumped up [MSRV] to 1.81 because for `#[expect]` attribute usage. ([a1192b5d]) +[a1192b5d]: /../../commit/a1192b5d1d7d6069b82d10f71d7fc4e0583897c0 [todo]: /../../commit/todo @@ -28,7 +31,7 @@ All user visible changes to this project will be documented in this file. This p ### BC Breaks - Upgraded to 0.23 version of `metrics` crate. ([#11], [#10]) -- Upgraded to 0.13 version of `metrics-util` crate. ([#11], [#10]) +- Upgraded to 0.17 version of `metrics-util` crate. ([#11], [#10]) - Bumped up [MSRV] to 1.72 because of newer dependencies versions. ([#11], [#10]) [#10]: /../../issues/10 diff --git a/Cargo.toml b/Cargo.toml index b0a6fdd..1910866 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,8 @@ include = ["/src/", "/CHANGELOG.md", "/LICENSE-APACHE", "/LICENSE-MIT", "/README [dependencies] arc-swap = "1.5" -metrics = { version = "0.23", default-features = false } -metrics-util = { version = "0.17", features = ["registry"], default-features = false } +metrics = { version = "0.24", default-features = false } +metrics-util = { version = "0.18", features = ["registry"], default-features = false } prometheus = { version = "0.13", default-features = false } sealed = "0.6" smallvec = "1.10" @@ -27,4 +27,4 @@ smallvec = "1.10" thiserror = "1.0.2" [dev-dependencies] -metrics-util = { version = "0.17", features = ["layer-filter"], default-features = false } +metrics-util = { version = "0.18", features = ["layer-filter"], default-features = false } diff --git a/src/metric.rs b/src/metric.rs index bfe77f3..a1344e2 100644 --- a/src/metric.rs +++ b/src/metric.rs @@ -84,6 +84,12 @@ impl metrics::HistogramFn for Metric { fn record(&self, value: f64) { self.0.observe(value); } + + fn record_many(&self, value: f64, count: usize) { + for _ in 0..count { + self.record(value); + } + } } /// Fallible [`Metric`] stored in [`metrics::Registry`]. @@ -180,6 +186,14 @@ where m.record(value); } } + + fn record_many(&self, value: f64, count: usize) { + if let Ok(m) = &*self.0 { + for _ in 0..count { + m.record(value); + } + } + } } /// [`prometheus`] metric with an ability to substitute its [`help` description] diff --git a/src/recorder/mod.rs b/src/recorder/mod.rs index 08f9f97..a554159 100644 --- a/src/recorder/mod.rs +++ b/src/recorder/mod.rs @@ -911,7 +911,7 @@ impl Builder { where S: failure::Strategy + Clone, L: Layer>, - >>::Output: metrics::Recorder + 'static, + >>::Output: metrics::Recorder + Sync + 'static, { let Self { storage, failure_strategy, layers } = self; let rec = Recorder { @@ -986,7 +986,7 @@ impl Builder { S: failure::Strategy + Clone, L: Layer>, >>::Output: - metrics::Recorder + 'static, + metrics::Recorder + Sync + 'static, { let Self { storage, failure_strategy, layers } = self; let rec = freezable::Recorder::wrap(Recorder { @@ -1065,7 +1065,8 @@ impl Builder { where S: failure::Strategy + Clone, L: Layer>, - >>::Output: metrics::Recorder + 'static, + >>::Output: + metrics::Recorder + Sync + 'static, { let Self { storage, failure_strategy, layers } = self; let rec = @@ -1139,7 +1140,7 @@ impl Builder { where S: failure::Strategy + Clone, L: Layer>, - >>::Output: metrics::Recorder + 'static, + >>::Output: metrics::Recorder + Sync + 'static, { self.try_build_and_install().unwrap_or_else(|e| { panic!( @@ -1203,7 +1204,7 @@ impl Builder { S: failure::Strategy + Clone, L: Layer>, >>::Output: - metrics::Recorder + 'static, + metrics::Recorder + Sync + 'static, { self.try_build_freezable_and_install().unwrap_or_else(|e| { panic!( @@ -1271,7 +1272,8 @@ impl Builder { where S: failure::Strategy + Clone, L: Layer>, - >>::Output: metrics::Recorder + 'static, + >>::Output: + metrics::Recorder + Sync + 'static, { self.try_build_frozen_and_install().unwrap_or_else(|e| { panic!(