Skip to content

Commit

Permalink
Merge branch 'master' into opt-remove-unnecessary-path-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
lucab authored May 5, 2024
2 parents 923bbfb + 04fce2f commit f6393ad
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 53 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.78.0
# Minimum supported Rust version (MSRV)
ACTION_MSRV_TOOLCHAIN: 1.57.0
ACTION_MSRV_TOOLCHAIN: 1.74.0
EXTRA_FEATURES: "protobuf push process"

jobs:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
19 changes: 12 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ license = "Apache-2.0"
name = "prometheus"
readme = "README.md"
repository = "https://github.com/tikv/rust-prometheus"
version = "0.13.3"

[badges]
travis-ci = { repository = "pingcap/rust-prometheus" }
version = "0.13.4"

[package.metadata.docs.rs]
features = ["nightly"]
Expand All @@ -32,14 +29,14 @@ 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]
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"] }
Expand Down Expand Up @@ -73,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"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
9 changes: 0 additions & 9 deletions examples/example_process_collector.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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"#
);
}
11 changes: 0 additions & 11 deletions examples/example_push.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,7 +23,6 @@ lazy_static! {
.unwrap();
}

#[cfg(feature = "push")]
fn main() {
let args: Vec<String> = env::args().collect();
let program = args[0].clone();
Expand Down Expand Up @@ -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"#
);
}
24 changes: 12 additions & 12 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 $(,)?) => {{
Expand Down Expand Up @@ -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 $(,)?) => {{
Expand Down Expand Up @@ -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)
}};
}

Expand Down Expand Up @@ -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)
}};
}

Expand Down Expand Up @@ -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)
}};
}

Expand Down Expand Up @@ -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)
}};
}

Expand Down Expand Up @@ -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)
}};
}

Expand Down Expand Up @@ -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 $(,)?) => {{
Expand Down Expand Up @@ -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 $(,)?) => {{
Expand Down
4 changes: 2 additions & 2 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions static-metric/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion static-metric/src/auto_flush_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ impl<'a> MetricBuilderContext<'a> {
})#local_suffix_call,
}
} else {
let prev_labels_ident = prev_labels_ident;
quote! {
#name: #member_type::from(
#(
Expand Down
1 change: 0 additions & 1 deletion static-metric/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ impl<'a> MetricBuilderContext<'a> {
})#local_suffix_call,
}
} else {
let prev_labels_ident = prev_labels_ident;
quote! {
#name: #member_type::from(
#(
Expand Down

0 comments on commit f6393ad

Please sign in to comment.