Skip to content

Commit b2de140

Browse files
authored
Merge branch 'master' into patch-1
2 parents fad40f9 + 04fce2f commit b2de140

File tree

11 files changed

+50
-53
lines changed

11 files changed

+50
-53
lines changed

.github/workflows/rust.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ on:
99
env:
1010
CARGO_TERM_COLOR: always
1111
# Pinned toolchain for linting and benchmarks
12-
ACTIONS_LINTS_TOOLCHAIN: 1.63.0
12+
ACTIONS_LINTS_TOOLCHAIN: 1.78.0
1313
# Minimum supported Rust version (MSRV)
14-
ACTION_MSRV_TOOLCHAIN: 1.57.0
14+
ACTION_MSRV_TOOLCHAIN: 1.74.0
1515
EXTRA_FEATURES: "protobuf push process"
1616

1717
jobs:
@@ -20,7 +20,7 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Checkout repository
23-
uses: actions/checkout@v3
23+
uses: actions/checkout@v4
2424
- name: Install toolchain
2525
uses: dtolnay/rust-toolchain@stable
2626
- name: cargo build
@@ -44,7 +44,7 @@ jobs:
4444
- "nightly"
4545
steps:
4646
- name: Checkout repository
47-
uses: actions/checkout@v3
47+
uses: actions/checkout@v4
4848
- name: Install toolchain
4949
uses: dtolnay/rust-toolchain@master
5050
with:
@@ -62,7 +62,7 @@ jobs:
6262
runs-on: ubuntu-latest
6363
steps:
6464
- name: Checkout repository
65-
uses: actions/checkout@v3
65+
uses: actions/checkout@v4
6666
- name: Install toolchain
6767
uses: dtolnay/rust-toolchain@master
6868
with:
@@ -78,7 +78,7 @@ jobs:
7878
runs-on: ubuntu-latest
7979
steps:
8080
- name: Checkout repository
81-
uses: actions/checkout@v3
81+
uses: actions/checkout@v4
8282
- name: Install toolchain
8383
uses: dtolnay/rust-toolchain@master
8484
with:
@@ -97,7 +97,7 @@ jobs:
9797
runs-on: ubuntu-latest
9898
steps:
9999
- name: Checkout repository
100-
uses: actions/checkout@v3
100+
uses: actions/checkout@v4
101101
- name: Install toolchain
102102
uses: dtolnay/rust-toolchain@master
103103
with:

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 0.13.4
4+
5+
- Improvement: Add PullingGauge (#405)
6+
7+
- Improvement: Let cargo know which example requires which features (#511)
8+
9+
- Bug fix: Prevent `clippy::ignored_unit_patterns` in macro expansions (#497)
10+
11+
- Internal change: Add CI job for minimum toolchain (MSRV) (#467)
12+
13+
- Internal change: Update CI to `actions/checkout@v4` (#499)
14+
15+
- Internal change: Update dependencies
16+
317
## 0.13.3
418

519
- Bug fix: Prevent ProcessCollector underflow with CPU time counter (#465)

Cargo.toml

+12-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ license = "Apache-2.0"
99
name = "prometheus"
1010
readme = "README.md"
1111
repository = "https://github.com/tikv/rust-prometheus"
12-
version = "0.13.3"
13-
14-
[badges]
15-
travis-ci = { repository = "pingcap/rust-prometheus" }
12+
version = "0.13.4"
1613

1714
[package.metadata.docs.rs]
1815
features = ["nightly"]
@@ -32,14 +29,14 @@ libc = { version = "^0.2", optional = true }
3229
parking_lot = "^0.12"
3330
protobuf = { version = "^2.0", optional = true }
3431
memchr = "^2.3"
35-
reqwest = { version = "^0.11", features = ["blocking"], optional = true }
32+
reqwest = { version = "^0.12", features = ["blocking"], optional = true }
3633
thiserror = "^1.0"
3734

3835
[target.'cfg(target_os = "linux")'.dependencies]
39-
procfs = { version = "^0.14", optional = true, default-features = false }
36+
procfs = { version = "^0.16", optional = true, default-features = false }
4037

4138
[dev-dependencies]
42-
criterion = "0.4"
39+
criterion = "0.5"
4340
getopts = "^0.2"
4441
hyper = { version = "^0.14", features = ["server", "http1", "tcp"] }
4542
tokio = { version = "^1.0", features = ["macros", "rt-multi-thread"] }
@@ -73,3 +70,11 @@ harness = false
7370
[[bench]]
7471
name = "text_encoder"
7572
harness = false
73+
74+
[[example]]
75+
name = "example_push"
76+
required-features = ["push"]
77+
78+
[[example]]
79+
name = "example_process_collector"
80+
required-features = ["process"]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Prometheus Rust client library
22

3-
[![Build Status](https://travis-ci.org/tikv/rust-prometheus.svg?branch=master)](https://travis-ci.org/pingcap/rust-prometheus)
3+
[![Build Status](https://github.com/tikv/rust-prometheus/actions/workflows/rust.yml/badge.svg)](https://github.com/tikv/rust-prometheus/actions/workflows/rust.yml)
44
[![docs.rs](https://docs.rs/prometheus/badge.svg)](https://docs.rs/prometheus)
55
[![crates.io](https://img.shields.io/crates/v/prometheus.svg)](https://crates.io/crates/prometheus)
66

examples/example_process_collector.rs

-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
22

3-
#[cfg(all(feature = "process", target_os = "linux"))]
43
fn main() {
54
use std::thread;
65
use std::time::Duration;
@@ -21,11 +20,3 @@ fn main() {
2120
thread::sleep(Duration::from_secs(1));
2221
}
2322
}
24-
25-
#[cfg(any(not(feature = "process"), not(target_os = "linux")))]
26-
fn main() {
27-
println!(
28-
r#"Please enable feature "process", try:
29-
cargo run --features="process" --example example_process_collector"#
30-
);
31-
}

examples/example_push.rs

-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
22

3-
#![cfg_attr(not(feature = "push"), allow(unused_imports, dead_code))]
4-
53
use std::env;
64
use std::thread;
75
use std::time;
@@ -25,7 +23,6 @@ lazy_static! {
2523
.unwrap();
2624
}
2725

28-
#[cfg(feature = "push")]
2926
fn main() {
3027
let args: Vec<String> = env::args().collect();
3128
let program = args[0].clone();
@@ -68,11 +65,3 @@ fn main() {
6865

6966
println!("Okay, please check the Pushgateway.");
7067
}
71-
72-
#[cfg(not(feature = "push"))]
73-
fn main() {
74-
println!(
75-
r#"Please enable feature "push", try:
76-
cargo run --features="push" --example example_push"#
77-
);
78-
}

src/macros.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn test_histogram_opts_trailing_comma() {
214214
macro_rules! register_counter {
215215
(@of_type $TYPE:ident, $OPTS:expr) => {{
216216
let counter = $crate::$TYPE::with_opts($OPTS).unwrap();
217-
$crate::register(Box::new(counter.clone())).map(|_| counter)
217+
$crate::register(Box::new(counter.clone())).map(|()| counter)
218218
}};
219219

220220
($OPTS:expr $(,)?) => {{
@@ -260,7 +260,7 @@ fn test_register_counter_trailing_comma() {
260260
macro_rules! register_counter_with_registry {
261261
(@of_type $TYPE: ident, $OPTS:expr, $REGISTRY:expr) => {{
262262
let counter = $crate::$TYPE::with_opts($OPTS).unwrap();
263-
$REGISTRY.register(Box::new(counter.clone())).map(|_| counter)
263+
$REGISTRY.register(Box::new(counter.clone())).map(|()| counter)
264264
}};
265265

266266
($OPTS:expr, $REGISTRY:expr $(,)?) => {{
@@ -361,14 +361,14 @@ fn test_register_int_counter() {
361361
macro_rules! __register_counter_vec {
362362
($TYPE:ident, $OPTS:expr, $LABELS_NAMES:expr) => {{
363363
let counter_vec = $crate::$TYPE::new($OPTS, $LABELS_NAMES).unwrap();
364-
$crate::register(Box::new(counter_vec.clone())).map(|_| counter_vec)
364+
$crate::register(Box::new(counter_vec.clone())).map(|()| counter_vec)
365365
}};
366366

367367
($TYPE:ident, $OPTS:expr, $LABELS_NAMES:expr, $REGISTRY:expr) => {{
368368
let counter_vec = $crate::$TYPE::new($OPTS, $LABELS_NAMES).unwrap();
369369
$REGISTRY
370370
.register(Box::new(counter_vec.clone()))
371-
.map(|_| counter_vec)
371+
.map(|()| counter_vec)
372372
}};
373373
}
374374

@@ -543,12 +543,12 @@ fn test_register_int_counter_vec() {
543543
macro_rules! __register_gauge {
544544
($TYPE:ident, $OPTS:expr) => {{
545545
let gauge = $crate::$TYPE::with_opts($OPTS).unwrap();
546-
$crate::register(Box::new(gauge.clone())).map(|_| gauge)
546+
$crate::register(Box::new(gauge.clone())).map(|()| gauge)
547547
}};
548548

549549
($TYPE:ident, $OPTS:expr, $REGISTRY:expr) => {{
550550
let gauge = $crate::$TYPE::with_opts($OPTS).unwrap();
551-
$REGISTRY.register(Box::new(gauge.clone())).map(|_| gauge)
551+
$REGISTRY.register(Box::new(gauge.clone())).map(|()| gauge)
552552
}};
553553
}
554554

@@ -670,14 +670,14 @@ macro_rules! register_int_gauge_with_registry {
670670
macro_rules! __register_gauge_vec {
671671
($TYPE:ident, $OPTS:expr, $LABELS_NAMES:expr $(,)?) => {{
672672
let gauge_vec = $crate::$TYPE::new($OPTS, $LABELS_NAMES).unwrap();
673-
$crate::register(Box::new(gauge_vec.clone())).map(|_| gauge_vec)
673+
$crate::register(Box::new(gauge_vec.clone())).map(|()| gauge_vec)
674674
}};
675675

676676
($TYPE:ident, $OPTS:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{
677677
let gauge_vec = $crate::$TYPE::new($OPTS, $LABELS_NAMES).unwrap();
678678
$REGISTRY
679679
.register(Box::new(gauge_vec.clone()))
680-
.map(|_| gauge_vec)
680+
.map(|()| gauge_vec)
681681
}};
682682
}
683683

@@ -917,7 +917,7 @@ macro_rules! register_histogram {
917917

918918
($HOPTS:expr $(,)?) => {{
919919
let histogram = $crate::Histogram::with_opts($HOPTS).unwrap();
920-
$crate::register(Box::new(histogram.clone())).map(|_| histogram)
920+
$crate::register(Box::new(histogram.clone())).map(|()| histogram)
921921
}};
922922
}
923923

@@ -974,7 +974,7 @@ macro_rules! register_histogram_with_registry {
974974
let histogram = $crate::Histogram::with_opts($HOPTS).unwrap();
975975
$REGISTRY
976976
.register(Box::new(histogram.clone()))
977-
.map(|_| histogram)
977+
.map(|()| histogram)
978978
}};
979979
}
980980

@@ -1030,7 +1030,7 @@ fn test_register_histogram_with_registry_trailing_comma() {
10301030
macro_rules! register_histogram_vec {
10311031
($HOPTS:expr, $LABELS_NAMES:expr $(,)?) => {{
10321032
let histogram_vec = $crate::HistogramVec::new($HOPTS, $LABELS_NAMES).unwrap();
1033-
$crate::register(Box::new(histogram_vec.clone())).map(|_| histogram_vec)
1033+
$crate::register(Box::new(histogram_vec.clone())).map(|()| histogram_vec)
10341034
}};
10351035

10361036
($NAME:expr, $HELP:expr, $LABELS_NAMES:expr $(,)?) => {{
@@ -1094,7 +1094,7 @@ macro_rules! register_histogram_vec_with_registry {
10941094
let histogram_vec = $crate::HistogramVec::new($HOPTS, $LABELS_NAMES).unwrap();
10951095
$REGISTRY
10961096
.register(Box::new(histogram_vec.clone()))
1097-
.map(|_| histogram_vec)
1097+
.map(|()| histogram_vec)
10981098
}};
10991099

11001100
($NAME:expr, $HELP:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{

src/registry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ impl RegistryCore {
183183

184184
// Write out MetricFamilies sorted by their name.
185185
mf_by_name
186-
.into_iter()
187-
.map(|(_, mut m)| {
186+
.into_values()
187+
.map(|mut m| {
188188
// Add registry namespace prefix, if any.
189189
if let Some(ref namespace) = self.prefix {
190190
let prefixed = format!("{}_{}", namespace, m.get_name());

static-metric/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ edition = "2018"
1313
proc-macro = true
1414

1515
[dependencies]
16-
syn = { version = "1.0", features = ["full", "extra-traits"] }
16+
syn = { version = "2.0", features = ["full", "extra-traits"] }
1717
proc-macro2 = "1.0"
1818
quote = "1.0"
1919
lazy_static = "1.4"
2020

2121
[dev-dependencies]
22-
criterion = "0.4"
22+
criterion = "0.5"
2323
prometheus = { path = "../" }
2424

2525
[features]

static-metric/src/auto_flush_builder.rs

-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ impl<'a> MetricBuilderContext<'a> {
714714
})#local_suffix_call,
715715
}
716716
} else {
717-
let prev_labels_ident = prev_labels_ident;
718717
quote! {
719718
#name: #member_type::from(
720719
#(

static-metric/src/builder.rs

-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ impl<'a> MetricBuilderContext<'a> {
300300
})#local_suffix_call,
301301
}
302302
} else {
303-
let prev_labels_ident = prev_labels_ident;
304303
quote! {
305304
#name: #member_type::from(
306305
#(

0 commit comments

Comments
 (0)