Macro kumo_prometheus::label_key

source ·
macro_rules! label_key {
    (pub struct $name:ident {
        $(
            pub $fieldname:ident: String,
        )*
    }
    ) => { ... };
}
Expand description

Used to declare a label key struct suitable for use in registering counters in the counter registry.

Usage looks like:

label_key! {
   pub struct LabelKey {
      pub label1: String,
   }
}

Always include the trailing comma after each struct field!

The macro will also generate BorrowedLabelKey and LabelKeyTrait types. The LabelKeyTrait is implemented for both LabelKey and BorrowedLabelKey and provides a key() method that will return a BorrowedLabelKey for either.

The BorrowedLabelKey offers a to_owned() method to return a LabelKey, and a label_pairs() method to return a fixed size array representation consisting of the key and value pairs:

assert_eq!(BorrowedLabelKey { label1: "hello"}.label_pairs(),
  [("label1", "hello")]
)