From 6e81890773ef82e3bcc6c080d406543da1fb8073 Mon Sep 17 00:00:00 2001 From: Croxx Date: Wed, 17 May 2023 16:28:32 +0800 Subject: [PATCH 01/10] bump MSRV to 1.60.0 (#491) Signed-off-by: MrCroxx --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 83db2d4f..fd933bf6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -11,7 +11,7 @@ env: # Pinned toolchain for linting and benchmarks ACTIONS_LINTS_TOOLCHAIN: 1.63.0 # Minimum supported Rust version (MSRV) - ACTION_MSRV_TOOLCHAIN: 1.57.0 + ACTION_MSRV_TOOLCHAIN: 1.60.0 EXTRA_FEATURES: "protobuf push process" jobs: From 7a9adcacd098128ee3017ad973afb841d1fc123e Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 20 Nov 2023 15:32:10 +0700 Subject: [PATCH 02/10] ci: Update badge info to not refer to Travis CI (#500) Signed-off-by: Bruce Mitchener --- Cargo.toml | 3 --- README.md | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e2197605..5cf82f25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,6 @@ readme = "README.md" repository = "https://github.com/tikv/rust-prometheus" version = "0.13.3" -[badges] -travis-ci = { repository = "pingcap/rust-prometheus" } - [package.metadata.docs.rs] features = ["nightly"] diff --git a/README.md b/README.md index 47b862ba..bb4b5617 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Prometheus Rust client library -[![Build Status](https://travis-ci.org/tikv/rust-prometheus.svg?branch=master)](https://travis-ci.org/pingcap/rust-prometheus) +[![Build Status](https://github.com/tikv/rust-prometheus/actions/workflows/rust.yml/badge.svg)](https://github.com/tikv/rust-prometheus/actions/workflows/rust.yml) [![docs.rs](https://docs.rs/prometheus/badge.svg)](https://docs.rs/prometheus) [![crates.io](https://img.shields.io/crates/v/prometheus.svg)](https://crates.io/crates/prometheus) From a72d8d7db880f57ade09dd9139c8b2c5501fbf2f Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 20 Nov 2023 16:27:48 +0700 Subject: [PATCH 03/10] Bump MSRV to 1.65 to fix CI. (#505) Signed-off-by: Bruce Mitchener --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fd933bf6..c90cf54c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,9 +9,9 @@ on: env: CARGO_TERM_COLOR: always # Pinned toolchain for linting and benchmarks - ACTIONS_LINTS_TOOLCHAIN: 1.63.0 + ACTIONS_LINTS_TOOLCHAIN: 1.65.0 # Minimum supported Rust version (MSRV) - ACTION_MSRV_TOOLCHAIN: 1.60.0 + ACTION_MSRV_TOOLCHAIN: 1.65.0 EXTRA_FEATURES: "protobuf push process" jobs: From 76a634587a95340db56959f5808ac0a6494f6282 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 20 Nov 2023 17:35:10 +0700 Subject: [PATCH 04/10] ci: Update to `actions/checkout@v4`. (#499) The main thing here is an update on the GitHub side for what version of Node is being used to stay ahead of their deprecation schedule. Signed-off-by: Bruce Mitchener --- .github/workflows/rust.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c90cf54c..11c951a9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install toolchain uses: dtolnay/rust-toolchain@stable - name: cargo build @@ -44,7 +44,7 @@ jobs: - "nightly" steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install toolchain uses: dtolnay/rust-toolchain@master with: @@ -62,7 +62,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install toolchain uses: dtolnay/rust-toolchain@master with: @@ -78,7 +78,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install toolchain uses: dtolnay/rust-toolchain@master with: @@ -97,7 +97,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install toolchain uses: dtolnay/rust-toolchain@master with: From f49c724df0e123520554664436da68e555593af0 Mon Sep 17 00:00:00 2001 From: Seth Westphal Date: Thu, 23 Nov 2023 04:56:11 -0600 Subject: [PATCH 05/10] cargo: update all dependencies (#504) * Update dependencies. Signed-off-by: Seth Westphal * Updates. Signed-off-by: Seth Westphal --------- Signed-off-by: Seth Westphal --- .github/workflows/rust.yml | 4 ++-- Cargo.toml | 4 ++-- static-metric/Cargo.toml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 11c951a9..27de644f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,9 +9,9 @@ on: env: CARGO_TERM_COLOR: always # Pinned toolchain for linting and benchmarks - ACTIONS_LINTS_TOOLCHAIN: 1.65.0 + ACTIONS_LINTS_TOOLCHAIN: 1.70.0 # Minimum supported Rust version (MSRV) - ACTION_MSRV_TOOLCHAIN: 1.65.0 + ACTION_MSRV_TOOLCHAIN: 1.70.0 EXTRA_FEATURES: "protobuf push process" jobs: diff --git a/Cargo.toml b/Cargo.toml index 5cf82f25..0ed1b828 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,10 +33,10 @@ reqwest = { version = "^0.11", features = ["blocking"], optional = true } thiserror = "^1.0" [target.'cfg(target_os = "linux")'.dependencies] -procfs = { version = "^0.14", optional = true, default-features = false } +procfs = { version = "^0.16", optional = true, default-features = false } [dev-dependencies] -criterion = "0.4" +criterion = "0.5" getopts = "^0.2" hyper = { version = "^0.14", features = ["server", "http1", "tcp"] } tokio = { version = "^1.0", features = ["macros", "rt-multi-thread"] } diff --git a/static-metric/Cargo.toml b/static-metric/Cargo.toml index 7827b183..88e0e735 100644 --- a/static-metric/Cargo.toml +++ b/static-metric/Cargo.toml @@ -13,13 +13,13 @@ edition = "2018" proc-macro = true [dependencies] -syn = { version = "1.0", features = ["full", "extra-traits"] } +syn = { version = "2.0", features = ["full", "extra-traits"] } proc-macro2 = "1.0" quote = "1.0" lazy_static = "1.4" [dev-dependencies] -criterion = "0.4" +criterion = "0.5" prometheus = { path = "../" } [features] From b7e874524f2b0580a28853e2042656a55b6484f0 Mon Sep 17 00:00:00 2001 From: Tamo Date: Fri, 3 May 2024 10:37:22 +0200 Subject: [PATCH 06/10] Let the cargo.toml know which example requires which features (#511) Signed-off-by: Tamo --- Cargo.toml | 8 ++++++++ examples/example_process_collector.rs | 9 --------- examples/example_push.rs | 11 ----------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0ed1b828..cf4aad24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,3 +70,11 @@ harness = false [[bench]] name = "text_encoder" harness = false + +[[example]] +name = "example_push" +required-features = ["push"] + +[[example]] +name = "example_process_collector" +required-features = ["process"] diff --git a/examples/example_process_collector.rs b/examples/example_process_collector.rs index b5720dde..48fbb7f4 100644 --- a/examples/example_process_collector.rs +++ b/examples/example_process_collector.rs @@ -1,6 +1,5 @@ // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. -#[cfg(all(feature = "process", target_os = "linux"))] fn main() { use std::thread; use std::time::Duration; @@ -21,11 +20,3 @@ fn main() { thread::sleep(Duration::from_secs(1)); } } - -#[cfg(any(not(feature = "process"), not(target_os = "linux")))] -fn main() { - println!( - r#"Please enable feature "process", try: - cargo run --features="process" --example example_process_collector"# - ); -} diff --git a/examples/example_push.rs b/examples/example_push.rs index 22d01953..c56a6eef 100644 --- a/examples/example_push.rs +++ b/examples/example_push.rs @@ -1,7 +1,5 @@ // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. -#![cfg_attr(not(feature = "push"), allow(unused_imports, dead_code))] - use std::env; use std::thread; use std::time; @@ -25,7 +23,6 @@ lazy_static! { .unwrap(); } -#[cfg(feature = "push")] fn main() { let args: Vec = env::args().collect(); let program = args[0].clone(); @@ -68,11 +65,3 @@ fn main() { println!("Okay, please check the Pushgateway."); } - -#[cfg(not(feature = "push"))] -fn main() { - println!( - r#"Please enable feature "push", try: - cargo run --features="push" --example example_push"# - ); -} From bf696d642c7ede1c694f93f9b088371e30dd96ab Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Fri, 3 May 2024 18:34:36 +0200 Subject: [PATCH 07/10] ci: bump MSRV to fix test jobs (#519) * ci: bump MSRV to fix test jobs Signed-off-by: Luca BRUNO * src: fix new linting warnings Signed-off-by: Luca BRUNO --------- Signed-off-by: Luca BRUNO --- .github/workflows/rust.yml | 4 ++-- src/registry.rs | 4 ++-- static-metric/src/auto_flush_builder.rs | 1 - static-metric/src/builder.rs | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 27de644f..5a09984e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,9 +9,9 @@ on: env: CARGO_TERM_COLOR: always # Pinned toolchain for linting and benchmarks - ACTIONS_LINTS_TOOLCHAIN: 1.70.0 + ACTIONS_LINTS_TOOLCHAIN: 1.78.0 # Minimum supported Rust version (MSRV) - ACTION_MSRV_TOOLCHAIN: 1.70.0 + ACTION_MSRV_TOOLCHAIN: 1.74.0 EXTRA_FEATURES: "protobuf push process" jobs: diff --git a/src/registry.rs b/src/registry.rs index a4be61f1..4d07d4bb 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -183,8 +183,8 @@ impl RegistryCore { // Write out MetricFamilies sorted by their name. mf_by_name - .into_iter() - .map(|(_, mut m)| { + .into_values() + .map(|mut m| { // Add registry namespace prefix, if any. if let Some(ref namespace) = self.prefix { let prefixed = format!("{}_{}", namespace, m.get_name()); diff --git a/static-metric/src/auto_flush_builder.rs b/static-metric/src/auto_flush_builder.rs index bb0454ca..efb25394 100644 --- a/static-metric/src/auto_flush_builder.rs +++ b/static-metric/src/auto_flush_builder.rs @@ -714,7 +714,6 @@ impl<'a> MetricBuilderContext<'a> { })#local_suffix_call, } } else { - let prev_labels_ident = prev_labels_ident; quote! { #name: #member_type::from( #( diff --git a/static-metric/src/builder.rs b/static-metric/src/builder.rs index 680c416c..37fa614a 100644 --- a/static-metric/src/builder.rs +++ b/static-metric/src/builder.rs @@ -300,7 +300,6 @@ impl<'a> MetricBuilderContext<'a> { })#local_suffix_call, } } else { - let prev_labels_ident = prev_labels_ident; quote! { #name: #member_type::from( #( From 439e3b8c14938a66352df4228ec32a9b707d1888 Mon Sep 17 00:00:00 2001 From: Matt Weber <30441572+mweber15@users.noreply.github.com> Date: Fri, 3 May 2024 12:49:46 -0400 Subject: [PATCH 08/10] Prevent `clippy::ignored_unit_patterns` in macro expansions (#497) This is a pedantic lint added in 1.73.0. Because it occurs inside a macro expansion, the lint is triggered from user code. The justification given by the lint definition is: > Matching with `()` explicitly instead of `_` outlines the fact that > the pattern contains no data. Also it would detect a type change that > `_` would ignore. Removing the lint requires a trivial change. It does introduce the possibility for compilation errors in the event the return type of the function currently returning `()` changes, but that seems like more of a benefit than a drawback. In these cases, it seems unlikely that the return type in question will change in the future. The user experience can be seen by linting the examples: ``` % cargo +nightly clippy --examples -- -A clippy::all -W clippy::ignored_unit_patterns -Z macro-backtrace Compiling prometheus v0.13.3 (/home/matt/src/rust-prometheus) ... warning: matching over `()` is more explicit --> /home/matt/src/rust-prometheus/src/macros.rs:217:58 | 214 | macro_rules! register_counter { | ----------------------------- | | | in this expansion of `register_counter!` (#1) | in this expansion of `register_counter!` (#2) | in this expansion of `register_counter!` (#3) ... 217 | $crate::register(Box::new(counter.clone())).map(|_| counter) | ^ ... 221 | register_counter!(@of_type Counter, $OPTS) | ------------------------------------------ in this macro invocation (#3) ... 225 | register_counter!(opts!($NAME, $HELP)) | -------------------------------------- in this macro invocation (#2) | ::: examples/example_push.rs:16:40 | 16 | static ref PUSH_COUNTER: Counter = register_counter!( | ________________________________________- 17 | | "example_push_total", 18 | | "Total number of prometheus client pushed." 19 | | ) | |_____- in this macro invocation (#1) | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ignored_unit_patterns = note: requested on the command line with `-W clippy::ignored-unit-patterns` ... ``` Signed-off-by: Matt Weber <30441572+mweber15@users.noreply.github.com> Co-authored-by: Luca Bruno --- src/macros.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 1dc9c45f..8095b2e9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -214,7 +214,7 @@ fn test_histogram_opts_trailing_comma() { macro_rules! register_counter { (@of_type $TYPE:ident, $OPTS:expr) => {{ let counter = $crate::$TYPE::with_opts($OPTS).unwrap(); - $crate::register(Box::new(counter.clone())).map(|_| counter) + $crate::register(Box::new(counter.clone())).map(|()| counter) }}; ($OPTS:expr $(,)?) => {{ @@ -260,7 +260,7 @@ fn test_register_counter_trailing_comma() { macro_rules! register_counter_with_registry { (@of_type $TYPE: ident, $OPTS:expr, $REGISTRY:expr) => {{ let counter = $crate::$TYPE::with_opts($OPTS).unwrap(); - $REGISTRY.register(Box::new(counter.clone())).map(|_| counter) + $REGISTRY.register(Box::new(counter.clone())).map(|()| counter) }}; ($OPTS:expr, $REGISTRY:expr $(,)?) => {{ @@ -361,14 +361,14 @@ fn test_register_int_counter() { macro_rules! __register_counter_vec { ($TYPE:ident, $OPTS:expr, $LABELS_NAMES:expr) => {{ let counter_vec = $crate::$TYPE::new($OPTS, $LABELS_NAMES).unwrap(); - $crate::register(Box::new(counter_vec.clone())).map(|_| counter_vec) + $crate::register(Box::new(counter_vec.clone())).map(|()| counter_vec) }}; ($TYPE:ident, $OPTS:expr, $LABELS_NAMES:expr, $REGISTRY:expr) => {{ let counter_vec = $crate::$TYPE::new($OPTS, $LABELS_NAMES).unwrap(); $REGISTRY .register(Box::new(counter_vec.clone())) - .map(|_| counter_vec) + .map(|()| counter_vec) }}; } @@ -543,12 +543,12 @@ fn test_register_int_counter_vec() { macro_rules! __register_gauge { ($TYPE:ident, $OPTS:expr) => {{ let gauge = $crate::$TYPE::with_opts($OPTS).unwrap(); - $crate::register(Box::new(gauge.clone())).map(|_| gauge) + $crate::register(Box::new(gauge.clone())).map(|()| gauge) }}; ($TYPE:ident, $OPTS:expr, $REGISTRY:expr) => {{ let gauge = $crate::$TYPE::with_opts($OPTS).unwrap(); - $REGISTRY.register(Box::new(gauge.clone())).map(|_| gauge) + $REGISTRY.register(Box::new(gauge.clone())).map(|()| gauge) }}; } @@ -670,14 +670,14 @@ macro_rules! register_int_gauge_with_registry { macro_rules! __register_gauge_vec { ($TYPE:ident, $OPTS:expr, $LABELS_NAMES:expr $(,)?) => {{ let gauge_vec = $crate::$TYPE::new($OPTS, $LABELS_NAMES).unwrap(); - $crate::register(Box::new(gauge_vec.clone())).map(|_| gauge_vec) + $crate::register(Box::new(gauge_vec.clone())).map(|()| gauge_vec) }}; ($TYPE:ident, $OPTS:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{ let gauge_vec = $crate::$TYPE::new($OPTS, $LABELS_NAMES).unwrap(); $REGISTRY .register(Box::new(gauge_vec.clone())) - .map(|_| gauge_vec) + .map(|()| gauge_vec) }}; } @@ -917,7 +917,7 @@ macro_rules! register_histogram { ($HOPTS:expr $(,)?) => {{ let histogram = $crate::Histogram::with_opts($HOPTS).unwrap(); - $crate::register(Box::new(histogram.clone())).map(|_| histogram) + $crate::register(Box::new(histogram.clone())).map(|()| histogram) }}; } @@ -974,7 +974,7 @@ macro_rules! register_histogram_with_registry { let histogram = $crate::Histogram::with_opts($HOPTS).unwrap(); $REGISTRY .register(Box::new(histogram.clone())) - .map(|_| histogram) + .map(|()| histogram) }}; } @@ -1030,7 +1030,7 @@ fn test_register_histogram_with_registry_trailing_comma() { macro_rules! register_histogram_vec { ($HOPTS:expr, $LABELS_NAMES:expr $(,)?) => {{ let histogram_vec = $crate::HistogramVec::new($HOPTS, $LABELS_NAMES).unwrap(); - $crate::register(Box::new(histogram_vec.clone())).map(|_| histogram_vec) + $crate::register(Box::new(histogram_vec.clone())).map(|()| histogram_vec) }}; ($NAME:expr, $HELP:expr, $LABELS_NAMES:expr $(,)?) => {{ @@ -1094,7 +1094,7 @@ macro_rules! register_histogram_vec_with_registry { let histogram_vec = $crate::HistogramVec::new($HOPTS, $LABELS_NAMES).unwrap(); $REGISTRY .register(Box::new(histogram_vec.clone())) - .map(|_| histogram_vec) + .map(|()| histogram_vec) }}; ($NAME:expr, $HELP:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{ From 6e435db331f7e269ae1a7498d5ef5b4787e71636 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 19:24:25 +0200 Subject: [PATCH 09/10] build(deps): update reqwest requirement from ^0.11 to ^0.12 (#516) Updates the requirements on [reqwest](https://github.com/seanmonstar/reqwest) to permit the latest version. - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/reqwest/compare/v0.11.0...v0.12.0) --- updated-dependencies: - dependency-name: reqwest dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Luca Bruno --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cf4aad24..776f622e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ libc = { version = "^0.2", optional = true } parking_lot = "^0.12" protobuf = { version = "^2.0", optional = true } memchr = "^2.3" -reqwest = { version = "^0.11", features = ["blocking"], optional = true } +reqwest = { version = "^0.12", features = ["blocking"], optional = true } thiserror = "^1.0" [target.'cfg(target_os = "linux")'.dependencies] From 04fce2f3bf81920c2607e6572dd9eba309969d22 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Sat, 4 May 2024 18:51:47 +0200 Subject: [PATCH 10/10] prometheus: release 0.13.4 (#520) Signed-off-by: Luca BRUNO --- CHANGELOG.md | 14 ++++++++++++++ Cargo.toml | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f2dd610..71f2e891 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.13.4 + +- Improvement: Add PullingGauge (#405) + +- Improvement: Let cargo know which example requires which features (#511) + +- Bug fix: Prevent `clippy::ignored_unit_patterns` in macro expansions (#497) + +- Internal change: Add CI job for minimum toolchain (MSRV) (#467) + +- Internal change: Update CI to `actions/checkout@v4` (#499) + +- Internal change: Update dependencies + ## 0.13.3 - Bug fix: Prevent ProcessCollector underflow with CPU time counter (#465) diff --git a/Cargo.toml b/Cargo.toml index 776f622e..a62b6296 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "Apache-2.0" name = "prometheus" readme = "README.md" repository = "https://github.com/tikv/rust-prometheus" -version = "0.13.3" +version = "0.13.4" [package.metadata.docs.rs] features = ["nightly"]