macro_rules! labels {
(@ { $($out:expr),* $(,)* } $(,)*) => { ... };
(@ { } $k:expr => $v:expr, $($rest:tt)*) => { ... };
(@ { $($out:expr),+ } $k:expr => $v:expr, $($rest:tt)*) => { ... };
($($args:tt)*) => { ... };
}
Expand description
Helper macro for generating a set of labels.
While a Label
can be generated manually, most users will tend towards the key => value format
commonly used for defining hashes/maps in many programming languages. This macro allows users
to do the exact same thing in calls that depend on [metrics_core::IntoLabels
].
ยงExamples
fn takes_labels<L: IntoLabels>(name: &str, labels: L) {
println!("name: {} labels: {:?}", name, labels.into_labels());
}
takes_labels("requests_processed", labels!("request_type" => "admin"));