[][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_name("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::stats.

Trait Implementations

impl Clone for Monitor[src]

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

Performs copy-assignment from source. Read more

impl Default for Monitor[src]

impl Debug for Monitor[src]

impl Prefixed for Monitor[src]

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

Append any name parts to the name's namespace.

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

Prepend any name parts to the name's namespace.

impl Flush for Monitor[src]

impl InputScope for Monitor[src]

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

Define a Counter.

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

Define a Marker.

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

Define a Timer.

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

Define a Gauge.

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

Define a Level.

Auto Trait Implementations

impl Send for Monitor

impl Sync for Monitor

Blanket Implementations

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

type Owned = T

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<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> Any for T where
    T: 'static + ?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> 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]

Deprecated since 0.7.2:

Use named() or add_name()

Append a name to the existing names. Return a clone of the component with the updated names.

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

Append a name to the existing names. Return a clone of the component with the updated names.

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

Replace any existing names with a single name. Return a clone of the component with the new name. If multiple names are required, add_name may also be used.

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

Append any name parts to the name's namespace.

default 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]

Flush this scope at regular intervals.

impl<T> Erased for T

impl<T> IntoResult for T[src]