Macro prometheus::opts

source ·
macro_rules! opts {
    ( $ NAME : expr , $ HELP : expr $ ( , $ CONST_LABELS : expr ) * $ ( , ) ? ) => { ... };
}
Expand description

Create an Opts.

Examples

let name = "test_opts";
let help = "test opts help";

let opts = opts!(name, help);
assert_eq!(opts.name, name);
assert_eq!(opts.help, help);

let opts = opts!(name, help, labels!{"test" => "hello", "foo" => "bar",});
assert_eq!(opts.const_labels.len(), 2);
assert!(opts.const_labels.get("foo").is_some());
assert_eq!(opts.const_labels.get("foo").unwrap(), "bar");

let opts = opts!(name,
                 help,
                 labels!{"test" => "hello", "foo" => "bar",},
                 labels!{"ans" => "42",});
assert_eq!(opts.const_labels.len(), 3);
assert!(opts.const_labels.get("ans").is_some());
assert_eq!(opts.const_labels.get("ans").unwrap(), "42");