Struct metrix::instruments::Panel
[−]
[src]
pub struct Panel<L> {
pub label: L,
pub name: Option<String>,
pub title: Option<String>,
pub description: Option<String>,
pub counter: Option<Counter>,
pub gauge: Option<Gauge>,
pub meter: Option<Meter>,
pub histogram: Option<Histogram>,
pub value_scaling: Option<ValueScaling>,
}The panel shows recorded observations of 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()));
Fields
label: L
name: Option<String>
title: Option<String>
description: Option<String>
counter: Option<Counter>
gauge: Option<Gauge>
meter: Option<Meter>
histogram: Option<Histogram>
value_scaling: Option<ValueScaling>
Methods
impl<L> Panel<L>[src]
fn new(label: L) -> Panel<L>[src]
Create a new Panel without a name.
fn with_name<T: Into<String>>(label: L, name: T) -> Panel<L>[src]
Create a new Panel with the given name
fn set_counter(&mut self, counter: Counter)[src]
fn set_gauge(&mut self, gauge: Gauge)[src]
fn set_meter(&mut self, meter: Meter)[src]
fn set_histogram(&mut self, histogram: Histogram)[src]
fn counter(&self) -> Option<&Counter>[src]
fn gauge(&self) -> Option<&Gauge>[src]
fn meter(&self) -> Option<&Meter>[src]
fn histogram(&self) -> Option<&Histogram>[src]
fn set_value_scaling(&mut self, value_scaling: ValueScaling)[src]
fn name(&self) -> Option<&str>[src]
Gets the name of this Panel
fn set_name<T: Into<String>>(&mut self, name: T)[src]
Set the name if this Panel.
The name is a path segment within a Snapshot
fn set_title<T: Into<String>>(&mut self, title: T)[src]
Sets the title of this Panel.
A title can be part of a descriptive Snapshot
fn set_description<T: Into<String>>(&mut self, description: T)[src]
Sets the description of this Panel.
A description can be part of a descriptive Snapshot
Trait Implementations
impl<L> PutsSnapshot for Panel<L>[src]
fn put_snapshot(&self, into: &mut Snapshot, descriptive: bool)[src]
Puts the current snapshot values into the given Snapshot thereby following the guidelines of PutsSnapshot. Read more
impl<L> Updates for Panel<L>[src]
fn update(&mut self, with: &Update)[src]
Update the internal state according to the given Update. Read more