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§
source§impl AppLabel
impl AppLabel
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 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
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));
}
}
Auto Trait Implementations§
impl Freeze for AppLabel
impl RefUnwindSafe for AppLabel
impl Send for AppLabel
impl Sync for AppLabel
impl Unpin for AppLabel
impl UnwindSafe for AppLabel
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more