[][src]Struct spirit_dipstick::Monitor

pub struct Monitor(_);

An inner node in a metrics tree.

This is just a thin wrapper around the AtomicBucket, hiding some of its functionality. That functionality is used for configuration of the backends and how metrics are collated and filtered, which is handled by this library.

If you want to use the library to just get the configuration and manage it manually, use AtomicBucket directly. This is for the use with Pipelines. See the crate example.

Cloning

Cloning is cheap and creates another „handle“ to the same bucket. Therefore, it can be distributed through the application and another layer of Arc is not needed.

Extraction of AtomicBucket

The bucket inside can be extracted by the Monitor::into_inner method, to access functionality hidden by this wrapper. Note that doing so and messing with the bucket might interfere with configuration from this library (the wrapper is more of a road bump than a full barrier).

Examples

use dipstick::{InputScope, Prefixed};
use spirit_dipstick::Monitor;

let monitor = Monitor::new();
// Plug the monitor.installer() into a pipeline here on startup
let sub_monitor = monitor.add_prefix("sub");
let timer = sub_monitor.timer("a-timer");
let timer_measurement = timer.start();
let counter = sub_monitor.counter("cnt");
counter.count(1);
timer.stop(timer_measurement);

Methods

impl Monitor[src]

pub fn new() -> Self[src]

Creates a new root node.

This becomes an independent node. Some backends can be installed into it later on and metrics or other nodes can be created under it.

pub fn into_inner(self) -> AtomicBucket[src]

Extracts the internal AtomicBucket

See the warning above about doing so ‒ the bucket is actually shared by all clones of the same Monitor and therefore you can interfere with the installed backends.

pub fn installer<F>(&self, stats: F) -> MonitorInstaller<F> where
    F: Fn(InputKind, MetricName, ScoreType) -> Option<(InputKind, MetricName, MetricValue)> + Send + Sync + 'static, 
[src]

Creates an installer for installing into this monitor.

This creates an installer which can be used inside a Pipeline to attach backends to it.

The stats is the same kind of filtering and selection function the dipstick uses in the AtomicBucket::set_stats.

Trait Implementations

impl Default for Monitor[src]

impl Clone for Monitor[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Monitor[src]

impl Prefixed for Monitor[src]

fn prefix_append<S>(&self, name: S) -> MetricName where
    S: Into<MetricName>, 
[src]

Append any name parts to the name's namespace.

fn prefix_prepend<S>(&self, name: S) -> MetricName where
    S: Into<MetricName>, 
[src]

Prepend any name parts to the name's namespace.

impl InputScope for Monitor[src]

fn counter(&self, name: &str) -> Counter[src]

Define a Counter.

fn marker(&self, name: &str) -> Marker[src]

Define a Marker.

fn timer(&self, name: &str) -> Timer[src]

Define a Timer.

fn gauge(&self, name: &str) -> Gauge[src]

Define a Gauge.

fn level(&self, name: &str) -> Level[src]

Define a Level.

impl Flush for Monitor[src]

Auto Trait Implementations

impl Send for Monitor

impl Sync for Monitor

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Prefixed for T where
    T: WithAttributes, 
[src]

fn get_prefixes(&self) -> &NameParts[src]

Returns namespace of component.

fn add_prefix<S>(&self, name: S) -> T where
    S: Into<String>, 
[src]

Adds a name part to any existing naming. Return a clone of the component with the updated naming.

fn prefix_append<S>(&self, name: S) -> MetricName where
    S: Into<MetricName>, 
[src]

Append any name parts to the name's namespace.

fn prefix_prepend<S>(&self, name: S) -> MetricName where
    S: Into<MetricName>, 
[src]

Prepend any name parts to the name's namespace.

impl<T> ScheduleFlush for T where
    T: 'static + InputScope + Send + Sync + Clone
[src]

fn flush_every(&self, period: Duration) -> CancelHandle[src]

Start a thread dedicated to flushing this scope at regular intervals.

impl<T> IntoResult for T[src]

impl<T> Erased for T