Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
# the rust-toolchain.toml file as metrics-observer requires 1.74 to build. See
# https://github.com/metrics-rs/metrics/pull/505#discussion_r1724092556 for more information.
matrix:
rust_version: ['stable', 'nightly', '1.71.1']
rust_version: ['stable', 'nightly', '1.74.0', '1.71.1']
include:
- rust_version: '1.71.1'
exclude-packages: '--exclude metrics-observer'
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [

[workspace.package]
edition = "2021"
rust-version = "1.71.1" # metrics-observer has a higher MSRV
license = "MIT"
repository = "https://github.com/metrics-rs/metrics"
homepage = "https://github.com/metrics-rs/metrics"
Expand Down
2 changes: 1 addition & 1 deletion metrics-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "metrics-benchmark"
version = "0.1.1-alpha.5"
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
edition = "2018"
rust-version = "1.71.1"
rust-version = { workspace = true }
publish = false

[dependencies]
Expand Down
6 changes: 3 additions & 3 deletions metrics-benchmark/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Generator {
Generator {
t0: None,
gauge: 0,
hist: HdrHistogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap(),
hist: HdrHistogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap(),
done,
rate_counter,
}
Expand Down Expand Up @@ -243,7 +243,7 @@ fn main() {
let producers = matches.opt_str("producers").unwrap_or_else(|| "1".to_owned()).parse().unwrap();
let mode = matches
.opt_str("mode")
.map(|s| if s.to_ascii_lowercase() == "fast" { "fast" } else { "slow" })
.map(|s| if s.eq_ignore_ascii_case("fast") { "fast" } else { "slow" })
.unwrap_or_else(|| "slow")
.to_owned();

Expand Down Expand Up @@ -286,7 +286,7 @@ fn main() {
let mut total = 0;
let mut t0 = Instant::now();

let mut upkeep_hist = HdrHistogram::<u64>::new_with_bounds(1, u64::max_value(), 3).unwrap();
let mut upkeep_hist = HdrHistogram::<u64>::new_with_bounds(1, u64::MAX, 3).unwrap();
for _ in 0..seconds {
let t1 = Instant::now();

Expand Down
2 changes: 1 addition & 1 deletion metrics-exporter-dogstatsd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "metrics-exporter-dogstatsd"
version = "0.9.6"
edition = { workspace = true}
rust-version = "1.71.1"
rust-version = { workspace = true }

description = "A metrics-compatible exporter for sending metrics to the Datadog Agent."
license = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions metrics-exporter-dogstatsd/src/forwarder/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl ClientState {

return result;
}
};
}
}
}
}
Expand Down Expand Up @@ -174,7 +174,7 @@ impl Forwarder {
if u32::try_from(payloads.len()).is_err() {
error!(num_payloads = payloads.len(), "Too many payloads to send.");
continue;
};
}

let splay_duration = next_flush.saturating_duration_since(Instant::now());
debug!(
Expand Down
4 changes: 2 additions & 2 deletions metrics-exporter-dogstatsd/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub(crate) enum Values<'a> {
Sampled(Drain<'a>),
}

impl<'a> Iterator for Values<'a> {
impl Iterator for Values<'_> {
type Item = f64;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -195,7 +195,7 @@ impl<'a> Iterator for Values<'a> {
}
}

impl<'a> ExactSizeIterator for Values<'a> {
impl ExactSizeIterator for Values<'_> {
fn len(&self) -> usize {
match self {
Values::Raw(values) => values.len(),
Expand Down
9 changes: 5 additions & 4 deletions metrics-exporter-dogstatsd/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,16 @@ impl PayloadWriter {
}
}

#[allow(clippy::doc_link_with_quotes)]
/// Iterator over all payloads written by a `PayloadWriter`.
///
/// The source payload buffer is immediately drained of consumed data during the creation of this iterator (as known as
/// The source payload buffer is immediately drained of consumed data during the creation of this iterator (also known as
/// ["pre-pooping our pants"][everyone_poops]). This ensures that the end state - the payload buffer contains only
/// preserved bytes (like length prefixes) - is established immediately.
///
/// [everyone_poops]: https://faultlore.com/blah/everyone-poops/
pub struct Payloads<'a> {
payloads_buf: Vec<u8>,
buf: Vec<u8>,
start: usize,
offsets: Drain<'a, usize>,
}
Expand All @@ -539,7 +540,7 @@ impl<'a> Payloads<'a> {
// for the next write operation.
let drain_size = offsets.last().copied().unwrap_or(0);
Self {
payloads_buf: payload_buf.drain(0..drain_size).collect(),
buf: payload_buf.drain(0..drain_size).collect(),
start: 0,
offsets: offsets.drain(..),
}
Expand All @@ -556,7 +557,7 @@ impl<'a> Payloads<'a> {
pub fn next_payload(&mut self) -> Option<&[u8]> {
let offset = self.offsets.next()?;

let offset_buf = &self.payloads_buf[self.start..offset];
let offset_buf = &self.buf[self.start..offset];
self.start = offset;

Some(offset_buf)
Expand Down
2 changes: 1 addition & 1 deletion metrics-exporter-prometheus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "metrics-exporter-prometheus"
version = "0.17.2"
edition = "2018"
rust-version = "1.71.1"
rust-version = { workspace = true }

description = "A metrics-compatible exporter for sending metrics to Prometheus."
license = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions metrics-exporter-prometheus/src/distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use metrics_util::{

const DEFAULT_SUMMARY_BUCKET_COUNT: NonZeroU32 = match NonZeroU32::new(3) {
Some(v) => v,
None => [][0],
None => unreachable!(),
};
const DEFAULT_SUMMARY_BUCKET_DURATION: Duration = Duration::from_secs(20);

Expand Down Expand Up @@ -123,7 +123,7 @@ impl DistributionBuilder {
}

/// Returns the distribution type for the given metric key.
pub fn get_distribution_type(&self, name: &str) -> &str {
pub fn get_distribution_type(&self, name: &str) -> &'static str {
if self.buckets.is_some() {
return "histogram";
}
Expand Down
2 changes: 1 addition & 1 deletion metrics-exporter-prometheus/src/exporter/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl PrometheusBuilder {
#[cfg(feature = "http-listener")]
let exporter_config = ExporterConfig::HttpListener {
destination: super::ListenDestination::Tcp(SocketAddr::new(
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
IpAddr::V4(Ipv4Addr::UNSPECIFIED),
9000,
)),
};
Expand Down
2 changes: 1 addition & 1 deletion metrics-exporter-prometheus/src/exporter/http_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl HttpListeningExporter {
HyperHttpBuilder::new().serve_connection(TokioIo::new(stream), service).await
{
warn!(error = ?err, "Error serving connection.");
};
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion metrics-exporter-prometheus/src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub fn sanitize_description(value: &str) -> String {
fn sanitize_label_value_or_description(value: &str, is_desc: bool) -> String {
// All Unicode characters are valid, but backslashes, double quotes, and line feeds must be
// escaped.
let mut sanitized = String::with_capacity(value.as_bytes().len());
let mut sanitized = String::with_capacity(value.len());

let mut previous_backslash = false;
for c in value.chars() {
Expand Down
2 changes: 0 additions & 2 deletions metrics-exporter-prometheus/src/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ impl Inner {
if delete_by_name {
wg.remove(&name);
}

continue;
}
}

Expand Down
2 changes: 1 addition & 1 deletion metrics-exporter-tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "metrics-exporter-tcp"
version = "0.11.1"
edition = "2018"
rust-version = "1.71.1"
rust-version = { workspace = true }

description = "A metrics-compatible exporter that outputs metrics to clients over TCP."
license = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion metrics-exporter-tcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ fn run_transport(
state: Arc<State>,
buffer_size: Option<usize>,
) {
let buffer_limit = buffer_size.unwrap_or(std::usize::MAX);
let buffer_limit = buffer_size.unwrap_or(usize::MAX);
let mut events = Events::with_capacity(1024);
let mut clients = HashMap::new();
let mut clients_to_remove = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion metrics-tracing-context/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "metrics-tracing-context"
version = "0.18.1"
edition = "2018"
rust-version = "1.71.1"
rust-version = { workspace = true }

description = "A crate to use tracing context as metrics labels."
license = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion metrics-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "metrics-util"
version = "0.20.0"
edition = "2018"
rust-version = "1.71.1"
rust-version = { workspace = true }

description = "Helper types/functions used by the metrics ecosystem."
license = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "metrics"
version = "0.24.2"
edition = "2018"
rust-version = "1.71.1"
rust-version = { workspace = true }

description = "A lightweight metrics facade."
license = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion metrics/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl Key {
}

/// Labels of this key, if they exist.
pub fn labels(&self) -> Iter<Label> {
pub fn labels(&self) -> Iter<'_, Label> {
self.labels.iter()
}

Expand Down
2 changes: 1 addition & 1 deletion metrics/src/recorder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ where
///
/// If a global recorder is set, it will be restored once the guard is dropped.
#[must_use]
pub fn set_default_local_recorder(recorder: &dyn Recorder) -> LocalRecorderGuard {
pub fn set_default_local_recorder(recorder: &dyn Recorder) -> LocalRecorderGuard<'_> {
LocalRecorderGuard::new(recorder)
}

Expand Down
5 changes: 0 additions & 5 deletions rust-toolchain.toml

This file was deleted.