This project is complete. We are now merging with https://github.com/brayniac/tic. The goals are simple
- Keep it fast
- Good enough for tokio metrics and/or linkerd-tcp to use as a metrics library
- You stay the main library owner I can help with different reporting types and integration in libraries
rust-metrics
Metrics are things you can use to safely & directly store metrics with little overhead. Metrics can be attached to a registry and that registry can be collected across a system. This registry also provides reporting services. Current reporters include:
- Prometheus with included prometheues reporter
- Graphite/Carbon/Whisper
- Console/Syslog/Journald (via stdout)
Contact us on #rust-metrics on Mozilla IRC.
...
let m = new;
m.mark;
let c = new;
c.inc;
let g = new;
g.set;
let mut h = configure
.max_value
.precision
.build
.unwrap;
h.increment_by.unwrap;
let mut reporter = new;
reporter.add;
reporter.add;
reporter.add;
// Add a histogram with labels even though they ignored in this reporter
reporter.addL;
while ...
reporter.stop;
Usage
Add this to your Cargo.toml
:
push only
= { ="0.2.0" }
prometheus pull support
= { ="0.2.0", =["prometheus"] }
And add this to your crate root:
extern crate metrics
Provided scripts in bin/
- build_docker This builds the default docker image
- generate_pb Generates the prometheus protocol buffer code
- run_docker This will run the docker container once it's been built (or download the last one i pushed)
- start_docker Use docker_compose to launch prometheus, carbon/graphite and clients which send them data
- webserver_with_prometheus Starts a webserver which runs with a prometheus reporter
- start_prometheus_example Use docker-compose to start a prometheus server & hook it up to webserver_with_prometheus
- webserver_with_carbon Starts a webserver with a carbon reporter
- start_carbon_example Use docker-compose to start graphite/carbon/whisper and hook it up to webserver_with_carbon
Many of these will only run if prometheus support is enabled
TBD
- C ffi
- js ffi
- Multi Reporter with thresholding
- Switch to https://github.com/pingcap/rust-prometheus
- Tested in Production at Scale on AWS (10k-20k) vms
- Metrics Benchmark
Local Development
cargo build # to build the code
cargo test # to run the tests
To use prometheus you will might need to read these directions
cargo build --features "prometheus" # To build code with prometheus support
License
rust-metrics
is primarily distributed under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE, LICENSE-MIT for details.
Copyright (c) 2016 Alex Newman.