Struct dipstick::AppLabel

source ·
pub struct AppLabel;
Expand description

Handle metric labels for the whole application (globals). App scope labels have the lowest lookup priority and serve as a fallback to other scopes.

Implementations§

Retrieve a value from the app scope.

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

Examples found in repository?
examples/text_format_label.rs (line 37)
32
33
34
35
36
37
38
39
40
41
42
43
fn main() {
    let counter = Stream::write_to_stderr()
        .formatting(MyFormat)
        .metrics()
        .counter("counter_a");
    AppLabel::set("abc", "xyz");
    loop {
        // report some metric values from our "application" loop
        counter.count(11);
        sleep(Duration::from_millis(500));
    }
}
More examples
Hide additional examples
examples/prometheus_labels.rs (line 12)
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.