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§
source§impl ThreadLabel
impl ThreadLabel
sourcepub fn set<S: Into<String>>(key: S, value: S)
pub fn set<S: Into<String>>(key: S, value: S)
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));
}
}