Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/cargo/reqwest-tw-0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
lucab authored May 3, 2024
2 parents 37f9eb2 + 439e3b8 commit f68122f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 38 deletions.
4 changes: 2 additions & 2 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.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:
Expand Down
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
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
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 f68122f

Please sign in to comment.