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§

Create a new Panel without a name.

Create a new Panel with the given name

👎Deprecated since 0.6.0: use add_instrument
👎Deprecated since 0.6.0: there will be no replacement

Gets the name of this Panel

Set the name if this Panel.

The name is a path segment within a Snapshot

Sets the title of this Panel.

A title can be part of a descriptive Snapshot

Sets the description of this Panel.

A description can be part of a descriptive Snapshot

Trait Implementations§

Puts the current snapshot values into the given Snapshot thereby following the guidelines of PutsSnapshot. Read more
Update the internal state according to the given Update. Read more

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.