Struct metrix::instruments::Counter [−][src]
pub struct Counter { /* fields omitted */ }
A simple ever increasing counter
Reacts to the following Observation
s:
Observation::Observed
(Update::Observations)Obervation::ObservedOne
(Update::Observation)Obervation::ObservedOneValue
(Update::ObservationWithValue)
Example
use std::time::Instant; use metrix::instruments::*; let mut counter = Counter::new_with_defaults("example"); let update = Update::Observation(Instant::now()); counter.update(&update); assert_eq!(1, counter.get());
Methods
impl Counter
[src]
impl Counter
pub fn new_with_defaults<T: Into<String>>(name: T) -> Counter
[src]
pub fn new_with_defaults<T: Into<String>>(name: T) -> Counter
pub fn inc(&mut self)
[src]
pub fn inc(&mut self)
Increase the stored value by one.
pub fn inc_by(&mut self, n: u64)
[src]
pub fn inc_by(&mut self, n: u64)
Increase the stored value by n
pub fn get(&self) -> u64
[src]
pub fn get(&self) -> u64
Get the current value
pub fn name(&self) -> &str
[src]
pub fn name(&self) -> &str
Gets the name of this Counter
pub fn set_name<T: Into<String>>(&mut self, name: T)
[src]
pub fn set_name<T: Into<String>>(&mut self, name: T)
Set the name if this Counter
.
The name is a path segment within a Snapshot
pub fn set_title<T: Into<String>>(&mut self, title: T)
[src]
pub fn set_title<T: Into<String>>(&mut self, title: T)
Sets the title
of this Counter
.
A title can be part of a descriptive Snapshot
pub fn set_description<T: Into<String>>(&mut self, description: T)
[src]
pub fn set_description<T: Into<String>>(&mut self, description: T)
Sets the description
of this Counter
.
A description can be part of a descriptive Snapshot
Trait Implementations
impl Instrument for Counter
[src]
impl Instrument for Counter
impl PutsSnapshot for Counter
[src]
impl PutsSnapshot for Counter
fn put_snapshot(&self, into: &mut Snapshot, descriptive: bool)
[src]
fn put_snapshot(&self, into: &mut Snapshot, descriptive: bool)
Puts the current snapshot values into the given Snapshot
thereby following the guidelines of PutsSnapshot
. Read more
impl Updates for Counter
[src]
impl Updates for Counter
fn update(&mut self, with: &Update)
[src]
fn update(&mut self, with: &Update)
Update the internal state according to the given Update
. Read more
impl Descriptive for Counter
[src]
impl Descriptive for Counter