Macro declare_static_counter

Source
macro_rules! declare_static_counter {
    ($name:ident, $key:expr_2021) => { ... };
}
Expand description

Create a thread safe static counter that can be incremeneted or decremented. This is useful to avoid creating temporary counters. You can safely create counters with the same name. They will be joined by the underlying runtime and are thread safe.

Example:

struct Url {
    pub path: String,
    pub proto: String,
}

declare_static_counter!(REQUESTS_RECEIVED, "requests_received");

REQUESTS_RECEIVED.add(40, kv_pairs!("path" => url.path, "proto" => url.proto))