Crate metrics_printer[][src]

This crate provides you with a metrics recorder that can print all metrics to a target of your choice in regular intervals.

It uses a thread to print, so it doesn’t interfere with other threads’ work directly.

Custom printing targets (e.g., logging frameworks) can be provided via the simple Printer trait, while default implementations for stdout and stderr are provided.

Example

use metrics::*;
use metrics_printer::*;

PrintRecorder::default().install().unwrap();
register_counter!("test.counter");
for _i in 0..300 {
    increment_counter!("test.counter");
    std::thread::sleep(Duration::from_millis(10));
}

Structs

PrintRecorder

A metrics recorder that collects metrics and regularly tried to print them.

StderrPrinter

Prints metrics to stderr

StdoutPrinter

Prints metrics to stdout

Constants

DEFAULT_PRINT_INTERVAL

The default interval between printing metrics

Traits

Printer

Logic to get the stringified metrics to some output device.

Functions

default_quantiles

The default set of quantiles to print.

init

Load and install the default recorder