dipstick/handbook/01_basics.md

1.0 KiB
Executable File

The dipstick handbook

This handbook's purpose is to get you started instrumenting your apps with dipstick and give an idea of what's possible.

For more details, consult the docs.

Overview

To achieve it's flexibility, Dipstick decouples the metrics inputs from the metric outputs. For example, incrementing a counter in the application may not result in immediate output to a file or to the network. Conversely, it is also possible that an app will output metrics data even though no values were recorded. While this makes things generally simpler, it requires the programmer to decide beforehand how metrics will be handled.

Static metrics

For speed and easier maintenance, metrics are usually defined statically:

#[macro_use] 
extern crate dipstick;

use dipstick::*;

metrics!("my_app" => {
    COUNTER_A: Counter = "counter_a";
});

fn main() {
    route_aggregate_metrics(to_stdout());
    COUNTER_A.count(11);
}

(Metric definition macros are just lazy_static! wrappers.)