Skip to content

Commit

Permalink
chore(deps): Bump metrics from 0.21.1 to 0.22.0 (#19463)
Browse files Browse the repository at this point in the history
* chore(deps): Bump metrics from 0.21.1 to 0.22.0

Bumps [metrics](https://github.com/metrics-rs/metrics) from 0.21.1 to 0.22.0.
- [Changelog](https://github.com/metrics-rs/metrics/blob/main/release.toml)
- [Commits](metrics-rs/metrics@metrics-v0.21.1...metrics-v0.22.0)

---
updated-dependencies:
- dependency-name: metrics
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Update metrics usage

* More test fixes

* Fix more tests

* Update versions

* Drop unused local recorder

* Init the global metrics recorder for tests

* Fix async test recorder usage with a wrapper type

* Simplify registry handling wrapper

* Cleanup test recorder future init

* Revert all of the `with_test_recorder` related changes

* Fix integration tests

* Fix goofy reformatting

* Fix loki internal event

* Fix check-events

* Fix licenses

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bruce Guenter <[email protected]>
  • Loading branch information
dependabot[bot] and bruceg authored Jul 22, 2024
1 parent fd35e1c commit b2aea48
Show file tree
Hide file tree
Showing 96 changed files with 857 additions and 721 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ updates:
patterns:
- "futures"
- "futures-util"
metrics:
patterns:
- "metrics"
- "metrics-tracing-context"
- "metrics-util"
graphql:
patterns:
- "async-graphql*"
Expand Down
82 changes: 14 additions & 68 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ members = [
chrono = { version = "0.4.37", default-features = false, features = ["clock", "serde"] }
clap = { version = "4.5.9", default-features = false, features = ["derive", "error-context", "env", "help", "std", "string", "usage", "wrap_help"] }
indexmap = { version = "2.2.6", default-features = false, features = ["serde", "std"] }
metrics = "0.22.3"
metrics-tracing-context = { version = "0.15.0", default-features = false }
metrics-util = { version = "0.16.3", default-features = false, features = ["registry"] }
pin-project = { version = "1.1.5", default-features = false }
proptest = { version = "1.5" }
proptest-derive = { version = "0.4.0" }
Expand Down Expand Up @@ -175,8 +178,8 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
tracing-tower = { git = "https://github.com/tokio-rs/tracing", default-features = false, rev = "e0642d949891546a3bb7e47080365ee7274f05cd" }

# Metrics
metrics = "0.21.1"
metrics-tracing-context = { version = "0.14.0", default-features = false }
metrics.workspace = true
metrics-tracing-context = { version = "0.15.0", default-features = false }

# AWS - Official SDK
aws-sdk-s3 = { version = "1.4.0", default-features = false, features = ["behavior-version-latest"], optional = true }
Expand Down
1 change: 0 additions & 1 deletion LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ lru-cache,https://github.com/contain-rs/lru-cache,MIT OR Apache-2.0,Stepan Kolts
lz4,https://github.com/10xGenomics/lz4-rs,MIT,"Jens Heyens <[email protected]>, Artem V. Navrotskiy <[email protected]>, Patrick Marks <[email protected]>"
macaddr,https://github.com/svartalf/rust-macaddr,Apache-2.0 OR MIT,svartalf <[email protected]>
mach,https://github.com/fitzgen/mach,BSD-2-Clause,"Nick Fitzgerald <[email protected]>, David Cuddeback <[email protected]>, Gonzalo Brito Gadeschi <[email protected]>"
mach2,https://github.com/JohnTitor/mach2,BSD-2-Clause OR MIT OR Apache-2.0,The mach2 Authors
malloc_buf,https://github.com/SSheldon/malloc_buf,MIT,Steven Sheldon
match_cfg,https://github.com/gnzlbg/match_cfg,MIT OR Apache-2.0,gnzlbg <[email protected]>
matchers,https://github.com/hawkw/matchers,MIT,Eliza Weisman <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions lib/vector-buffers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ derivative = { version = "2.2.0", default-features = false }
fslock = { version = "0.2.1", default-features = false, features = ["std"] }
futures = { version = "0.3.30", default-features = false, features = ["std"] }
memmap2 = { version = "0.9.4", default-features = false }
metrics = "0.21.1"
metrics.workspace = true
num-traits = { version = "0.2.19", default-features = false }
paste = "1.0.15"
pin-project.workspace = true
Expand All @@ -38,8 +38,8 @@ clap.workspace = true
criterion = { version = "0.5", features = ["html_reports", "async_tokio"] }
crossbeam-queue = "0.3.11"
hdrhistogram = "7.5.4"
metrics-tracing-context = { version = "0.14.0", default-features = false }
metrics-util = { version = "0.15.1", default-features = false, features = ["debugging"] }
metrics-tracing-context.workspace = true
metrics-util = { workspace = true, features = ["debugging"] }
once_cell = "1.19"
proptest = "1.5"
quickcheck = "1.0"
Expand Down
8 changes: 3 additions & 5 deletions lib/vector-buffers/benches/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ pub async fn setup<const N: usize>(
}

pub fn init_instrumentation() {
if metrics::try_recorder().is_none() {
let subscriber = tracing_subscriber::Registry::default().with(MetricsLayer::new());
tracing::subscriber::set_global_default(subscriber).unwrap();

let subscriber = tracing_subscriber::Registry::default().with(MetricsLayer::new());
if tracing::subscriber::set_global_default(subscriber).is_ok() {
let recorder = TracingContextLayer::all().layer(DebuggingRecorder::new());
metrics::set_boxed_recorder(Box::new(recorder)).unwrap();
metrics::set_global_recorder(recorder).unwrap();
}
}

Expand Down
48 changes: 28 additions & 20 deletions lib/vector-buffers/src/internal_events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::time::Duration;

use metrics::{counter, decrement_gauge, gauge, increment_gauge, register_histogram, Histogram};
use metrics::{counter, gauge, histogram, Histogram};
use vector_common::{
internal_event::{error_type, InternalEvent},
registered_event,
Expand All @@ -16,10 +16,12 @@ impl InternalEvent for BufferCreated {
#[allow(clippy::cast_precision_loss)]
fn emit(self) {
if self.max_size_events != 0 {
gauge!("buffer_max_event_size", self.max_size_events as f64, "stage" => self.idx.to_string());
gauge!("buffer_max_event_size", "stage" => self.idx.to_string())
.set(self.max_size_events as f64);
}
if self.max_size_bytes != 0 {
gauge!("buffer_max_byte_size", self.max_size_bytes as f64, "stage" => self.idx.to_string());
gauge!("buffer_max_byte_size", "stage" => self.idx.to_string())
.set(self.max_size_bytes as f64);
}
}
}
Expand All @@ -33,10 +35,13 @@ pub struct BufferEventsReceived {
impl InternalEvent for BufferEventsReceived {
#[allow(clippy::cast_precision_loss)]
fn emit(self) {
counter!("buffer_received_events_total", self.count, "stage" => self.idx.to_string());
counter!("buffer_received_bytes_total", self.byte_size, "stage" => self.idx.to_string());
increment_gauge!("buffer_events", self.count as f64, "stage" => self.idx.to_string());
increment_gauge!("buffer_byte_size", self.byte_size as f64, "stage" => self.idx.to_string());
counter!("buffer_received_events_total", "stage" => self.idx.to_string())
.increment(self.count);
counter!("buffer_received_bytes_total", "stage" => self.idx.to_string())
.increment(self.byte_size);
gauge!("buffer_events", "stage" => self.idx.to_string()).increment(self.count as f64);
gauge!("buffer_byte_size", "stage" => self.idx.to_string())
.increment(self.byte_size as f64);
}
}

Expand All @@ -49,10 +54,12 @@ pub struct BufferEventsSent {
impl InternalEvent for BufferEventsSent {
#[allow(clippy::cast_precision_loss)]
fn emit(self) {
counter!("buffer_sent_events_total", self.count, "stage" => self.idx.to_string());
counter!("buffer_sent_bytes_total", self.byte_size, "stage" => self.idx.to_string());
decrement_gauge!("buffer_events", self.count as f64, "stage" => self.idx.to_string());
decrement_gauge!("buffer_byte_size", self.byte_size as f64, "stage" => self.idx.to_string());
counter!("buffer_sent_events_total", "stage" => self.idx.to_string()).increment(self.count);
counter!("buffer_sent_bytes_total", "stage" => self.idx.to_string())
.increment(self.byte_size);
gauge!("buffer_events", "stage" => self.idx.to_string()).decrement(self.count as f64);
gauge!("buffer_byte_size", "stage" => self.idx.to_string())
.decrement(self.byte_size as f64);
}
}

Expand Down Expand Up @@ -86,11 +93,12 @@ impl InternalEvent for BufferEventsDropped {
);
}
counter!(
"buffer_discarded_events_total", self.count,
"intentional" => intentional_str,
);
decrement_gauge!("buffer_events", self.count as f64, "stage" => self.idx.to_string());
decrement_gauge!("buffer_byte_size", self.byte_size as f64, "stage" => self.idx.to_string());
"buffer_discarded_events_total", "intentional" => intentional_str,
)
.increment(self.count);
gauge!("buffer_events", "stage" => self.idx.to_string()).decrement(self.count as f64);
gauge!("buffer_byte_size", "stage" => self.idx.to_string())
.decrement(self.byte_size as f64);
}
}

Expand All @@ -110,19 +118,19 @@ impl InternalEvent for BufferReadError {
internal_log_rate_limit = true,
);
counter!(
"buffer_errors_total", 1,
"error_code" => self.error_code,
"buffer_errors_total", "error_code" => self.error_code,
"error_type" => "reader_failed",
"stage" => "processing",
);
)
.increment(1);
}
}

registered_event! {
BufferSendDuration {
stage: usize,
} => {
send_duration: Histogram = register_histogram!("buffer_send_duration_seconds", "stage" => self.stage.to_string()),
send_duration: Histogram = histogram!("buffer_send_duration_seconds", "stage" => self.stage.to_string()),
}

fn emit(&self, duration: Duration) {
Expand Down
2 changes: 1 addition & 1 deletion lib/vector-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ crossbeam-utils = { version = "0.8.20", default-features = false }
derivative = { version = "2.2.0", default-features = false }
futures = { version = "0.3.30", default-features = false, features = ["std"] }
indexmap.workspace = true
metrics = "0.21.1"
metrics.workspace = true
nom = { version = "7", optional = true }
ordered-float = { version = "4.2.1", default-features = false }
paste = "1.0.15"
Expand Down
4 changes: 2 additions & 2 deletions lib/vector-common/src/internal_event/bytes_received.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use metrics::{register_counter, Counter};
use metrics::{counter, Counter};

use super::{ByteSize, Protocol, SharedString};

crate::registered_event!(
BytesReceived {
protocol: SharedString,
} => {
received_bytes: Counter = register_counter!("component_received_bytes_total", "protocol" => self.protocol.clone()),
received_bytes: Counter = counter!("component_received_bytes_total", "protocol" => self.protocol.clone()),
protocol: SharedString = self.protocol,
}

Expand Down
4 changes: 2 additions & 2 deletions lib/vector-common/src/internal_event/bytes_sent.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use metrics::{register_counter, Counter};
use metrics::{counter, Counter};
use tracing::trace;

use super::{ByteSize, Protocol, SharedString};
Expand All @@ -7,7 +7,7 @@ crate::registered_event!(
BytesSent {
protocol: SharedString,
} => {
bytes_sent: Counter = register_counter!("component_sent_bytes_total", "protocol" => self.protocol.clone()),
bytes_sent: Counter = counter!("component_sent_bytes_total", "protocol" => self.protocol.clone()),
protocol: SharedString = self.protocol,
}

Expand Down
4 changes: 2 additions & 2 deletions lib/vector-common/src/internal_event/cached_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ where
#[cfg(test)]
mod tests {
#![allow(unreachable_pub)]
use metrics::{register_counter, Counter};
use metrics::{counter, Counter};

use super::*;

Expand All @@ -101,7 +101,7 @@ mod tests {
dynamic: String,
} => {
event: Counter = {
register_counter!("test_event_total", "fixed" => self.fixed, "dynamic" => self.dynamic)
counter!("test_event_total", "fixed" => self.fixed, "dynamic" => self.dynamic)
},
}

Expand Down
Loading

0 comments on commit b2aea48

Please sign in to comment.