Crate libcantal [−] [src]
A library that exposes metrics sent to cantal
See mmap protocol for more information about the protocol.
Example
use libcantal::{Counter, Integer, Value, start, print}; // Declare metrics as static variables, so you can use it in a module // freely, i.e. increment/decrement at any time lazy_static! { static ref COUNTER: Counter = Counter::new(); static ref INTEGER: Integer = Integer::new(); } // Put metrics in a collection let metrics = [ (json!({"metric": "counter"}), &*COUNTER as &Value), (json!({"metric": "integer"}), &*INTEGER as &Value), ]; // The collection guard. When it's alive, all the metrics are exposed let _coll = start(&metrics[..]).expect("cantal works"); // ... // Somewhere later use the metrics: COUNTER.incr(1); INTEGER.set((COUNTER.get() / 7) as i64); // And at any time you can print the collection for debugging print(&metrics[..], stdout()).ok();
Structs
ActiveCollection |
An active collection currently publishing metrics |
Counter |
A kind of metric ( |
Error |
Error of exporting metrics |
Integer |
A kind of metric ( |
Json |
A helper that allows to serialize a collection of metrics as JSON |
Enums
LevelKind |
A kind of level (gauge) metric, only used for |
RawType |
A raw type of metric, only used for |
Traits
Collection |
A collection of metrics |
Name |
Name of the metric |
NameVisitor |
A structure used to serialize |
Value |
A value stored in a collection |
Visitor |
A trait used to enumerate a collection |
Functions
Print all metrics of a collection to a file |
|
start |
Start publishing metrics |
start_with_reading |
Start publishing metrics by reading old values first |