pub struct Probe(/* private fields */);Expand description
The interface to reading probe.
Implementations§
Source§impl Probe
impl Probe
Sourcepub fn new<W: Write + Send + 'static>(write: W) -> ReadingsResult<Probe>
pub fn new<W: Write + Send + 'static>(write: W) -> ReadingsResult<Probe>
Creates a probe logging its data to Write implementation (usually a file).
Sourcepub fn register_i64<S: AsRef<str>>(
&mut self,
name: S,
) -> ReadingsResult<Arc<AtomicI64>>
pub fn register_i64<S: AsRef<str>>( &mut self, name: S, ) -> ReadingsResult<Arc<AtomicI64>>
Register an i64 used-defined metric.
Must be called prior to the first call to log_event or spawn_heartbeat.
The result is shared AtomicI64 that can be used by client code to share communicate updates with the probe.
TODO: type-enforce this using the Builder pattern
Sourcepub fn spawn_heartbeat(&mut self, interval: Duration) -> ReadingsResult<()>
pub fn spawn_heartbeat(&mut self, interval: Duration) -> ReadingsResult<()>
Spawn a thread that will record all vitals at every “interval”.
Sourcepub fn log_event(&self, event: &str) -> ReadingsResult<()>
pub fn log_event(&self, event: &str) -> ReadingsResult<()>
Log an individual event with a label and the current values of metrics.
Sourcepub fn get_i64<S: AsRef<str>>(&self, name: S) -> Option<Arc<AtomicI64>>
pub fn get_i64<S: AsRef<str>>(&self, name: S) -> Option<Arc<AtomicI64>>
Recover a pre-registered used-defined metrics from the probe.
The result is shared AtomicI64 that can be used by client code to share communicate updates with the probe.
It is more efficient for the client code to keep the shared AtomicI64 somewhere handy than calling this at every update. Nevertheless, it allows for intermediate code to just have to propagate the probe without worrying about the various metrics that the underlying code may need.