Skip to content

Commit

Permalink
Upgrade metrics crate from 0.23 to 0.24 version
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Oct 21, 2024
1 parent 2fe0020 commit 7398888
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 }
14 changes: 14 additions & 0 deletions src/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ impl metrics::HistogramFn for Metric<prometheus::Histogram> {
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`].
Expand Down Expand Up @@ -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]
Expand Down
14 changes: 8 additions & 6 deletions src/recorder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ impl<S, L> Builder<S, L> {
where
S: failure::Strategy + Clone,
L: Layer<Recorder<S>>,
<L as Layer<Recorder<S>>>::Output: metrics::Recorder + 'static,
<L as Layer<Recorder<S>>>::Output: metrics::Recorder + Sync + 'static,
{
let Self { storage, failure_strategy, layers } = self;
let rec = Recorder {
Expand Down Expand Up @@ -986,7 +986,7 @@ impl<S, L> Builder<S, L> {
S: failure::Strategy + Clone,
L: Layer<freezable::Recorder<S>>,
<L as Layer<freezable::Recorder<S>>>::Output:
metrics::Recorder + 'static,
metrics::Recorder + Sync + 'static,
{
let Self { storage, failure_strategy, layers } = self;
let rec = freezable::Recorder::wrap(Recorder {
Expand Down Expand Up @@ -1065,7 +1065,8 @@ impl<S, L> Builder<S, L> {
where
S: failure::Strategy + Clone,
L: Layer<frozen::Recorder<S>>,
<L as Layer<frozen::Recorder<S>>>::Output: metrics::Recorder + 'static,
<L as Layer<frozen::Recorder<S>>>::Output:
metrics::Recorder + Sync + 'static,
{
let Self { storage, failure_strategy, layers } = self;
let rec =
Expand Down Expand Up @@ -1139,7 +1140,7 @@ impl<S, L> Builder<S, L> {
where
S: failure::Strategy + Clone,
L: Layer<Recorder<S>>,
<L as Layer<Recorder<S>>>::Output: metrics::Recorder + 'static,
<L as Layer<Recorder<S>>>::Output: metrics::Recorder + Sync + 'static,
{
self.try_build_and_install().unwrap_or_else(|e| {
panic!(
Expand Down Expand Up @@ -1203,7 +1204,7 @@ impl<S, L> Builder<S, L> {
S: failure::Strategy + Clone,
L: Layer<freezable::Recorder<S>>,
<L as Layer<freezable::Recorder<S>>>::Output:
metrics::Recorder + 'static,
metrics::Recorder + Sync + 'static,
{
self.try_build_freezable_and_install().unwrap_or_else(|e| {
panic!(
Expand Down Expand Up @@ -1271,7 +1272,8 @@ impl<S, L> Builder<S, L> {
where
S: failure::Strategy + Clone,
L: Layer<frozen::Recorder<S>>,
<L as Layer<frozen::Recorder<S>>>::Output: metrics::Recorder + 'static,
<L as Layer<frozen::Recorder<S>>>::Output:
metrics::Recorder + Sync + 'static,
{
self.try_build_frozen_and_install().unwrap_or_else(|e| {
panic!(
Expand Down

0 comments on commit 7398888

Please sign in to comment.