Struct dipstick::ThreadLabel

source ·
pub struct ThreadLabel;
Expand description

Handle metric labels for the current thread. App scope labels have the lowest lookup priority and serve as a fallback to other scopes.

Implementations§

Retrieve a value from the thread scope.

Set a new value for the thread scope. Replaces any previous value for the key.

Examples found in repository?
examples/prometheus_labels.rs (line 13)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fn main() {
    let metrics = Prometheus::push_to("http://localhost:9091/metrics/job/prometheus_example")
        .expect("Prometheus Socket")
        .named("my_app")
        .metrics();

    AppLabel::set("abc", "456");
    ThreadLabel::set("xyz", "123");

    loop {
        metrics.counter("counter_a").count(123);
        metrics.timer("timer_a").interval_us(2000000);
        std::thread::sleep(Duration::from_millis(40));
    }
}

Unset a value for the app scope. Has no effect if key was not set.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.