Struct metrix::instruments::Panel
source · pub struct Panel<L> { /* private fields */ }
Expand description
The panel shows recorded observations with the same label in different representations.
Let’s say you want to monitor the successful requests of a specific endpoint of your REST API. You would then create a panel for this and might want to add a counter and a meter and a histogram to track latencies.
Example
use std::time::Instant;
use metrix::instruments::*;
#[derive(Clone, PartialEq, Eq)]
struct SuccessfulRequests;
let counter = Counter::new_with_defaults("count");
let gauge = Gauge::new_with_defaults("last_latency");
let meter = Meter::new_with_defaults("per_second");
let histogram = Histogram::new_with_defaults("latencies");
assert_eq!(0, counter.get());
assert_eq!(None, gauge.get());
let mut panel = Panel::with_name(SuccessfulRequests, "succesful_requests");
panel.set_counter(counter);
panel.set_gauge(gauge);
panel.set_meter(meter);
panel.set_histogram(histogram);
let update = Update::ObservationWithValue(12, Instant::now());
panel.update(&update);
assert_eq!(Some(1), panel.counter().map(|c| c.get()));
assert_eq!(Some(12), panel.gauge().and_then(|g| g.get()));
Implementations§
source§impl<L> Panel<L>
impl<L> Panel<L>
sourcepub fn with_name<T: Into<String>>(label: L, name: T) -> Panel<L>
pub fn with_name<T: Into<String>>(label: L, name: T) -> Panel<L>
Create a new Panel
with the given name
pub fn set_counter(&mut self, counter: Counter)
pub fn counter(&self) -> Option<&Counter>
pub fn set_gauge(&mut self, gauge: Gauge)
pub fn gauge(&self) -> Option<&Gauge>
pub fn set_meter(&mut self, meter: Meter)
pub fn meter(&self) -> Option<&Meter>
pub fn set_histogram(&mut self, histogram: Histogram)
pub fn histogram(&self) -> Option<&Histogram>
pub fn set_staircase_timer(&mut self, timer: StaircaseTimer)
👎Deprecated since 0.6.0: use add_instrument
pub fn staircase_timer(&self) -> Option<&StaircaseTimer>
👎Deprecated since 0.6.0: there will be no replacement
pub fn add_snapshooter<T: PutsSnapshot>(&mut self, snapshooter: T)
pub fn snapshooters(&self) -> Vec<&dyn PutsSnapshot>
pub fn add_instrument<I: Instrument>(&mut self, instrument: I)
pub fn instruments(&self) -> Vec<&dyn Instrument>
pub fn set_value_scaling(&mut self, value_scaling: ValueScaling)
sourcepub fn set_name<T: Into<String>>(&mut self, name: T)
pub fn set_name<T: Into<String>>(&mut self, name: T)
Set the name if this Panel
.
The name is a path segment within a Snapshot
sourcepub fn set_title<T: Into<String>>(&mut self, title: T)
pub fn set_title<T: Into<String>>(&mut self, title: T)
Sets the title
of this Panel
.
A title can be part of a descriptive Snapshot
sourcepub fn set_description<T: Into<String>>(&mut self, description: T)
pub fn set_description<T: Into<String>>(&mut self, description: T)
Sets the description
of this Panel
.
A description can be part of a descriptive Snapshot