Macro histogram_opts
macro_rules! histogram_opts { ($NAME:expr, $HELP:expr $(,)?) => { ... }; ($NAME:expr, $HELP:expr, $BUCKETS:expr $(,)?) => { ... }; ($NAME:expr, $HELP:expr, $BUCKETS:expr, $CONST_LABELS:expr $(,)?) => { ... }; }
Expand description
Create a [HistogramOpts
][crate::HistogramOpts].
ยงExamples
let name = "test_histogram_opts";
let help = "test opts help";
let opts = histogram_opts!(name, help);
assert_eq!(opts.common_opts.name, name);
assert_eq!(opts.common_opts.help, help);
let opts = histogram_opts!(name, help, linear_buckets(1.0, 0.5, 4).unwrap());
assert_eq!(opts.common_opts.name, name);
assert_eq!(opts.common_opts.help, help);
assert_eq!(opts.buckets.len(), 4);
let opts = histogram_opts!(name,
help,
vec![1.0, 2.0],
labels!{"key".to_string() => "value".to_string(),});
assert_eq!(opts.common_opts.name, name);
assert_eq!(opts.common_opts.help, help);
assert_eq!(opts.buckets.len(), 2);
assert!(opts.common_opts.const_labels.get("key").is_some());
assert_eq!(opts.common_opts.const_labels.get("key").unwrap(), "value");