Trait MetricManager

Source
pub trait MetricManager {
    // Required method
    fn initialise_birth(&self, bi: &mut BirthInitializer);
}
Expand description

A trait for implementing a type that defines a collection of metrics.

This trait acts as an interface the library uses to query a type about what metrics it has so that birth messages can be created.

§Examples

use srad_eon::{MetricManager, BirthInitializer, BirthMetricDetails};

struct MyMetricManager {
  counter: i32
};

impl MetricManager for MyMetricManager {
    fn initialise_birth(&self, bi: &mut BirthInitializer) {
        // Register metrics
        bi.register_metric(BirthMetricDetails::new_with_initial_value("my_counter",  self.counter).use_alias(true));
    }
}

Required Methods§

Source

fn initialise_birth(&self, bi: &mut BirthInitializer)

Initialises the set of metrics to be included in a birth or rebirth message.

This method is called whenever the library needs to generate a birth message payload for the node or device
that uses the type which implements MetricManager

Implementors§