Epimetheus
==========
An easy-to-use prometheus-compatible metrics library.
Epimetheus is probably the easiest way to get your Rust application serving metrics.
Just set the metrics, and everything else happens automatically.
Watch your hashmaps grow!
```rust
metric!(my_data_len).set(my_data.len());
metric!(my_data_cap).set(my_data.capacity());
```
Monitor the latency of your functions!
```rust
let start = Instant::now();
my_function();
metric!(my_function_duration_sum).add(start.elapsed().as_secs_f64());
metric!(my_function_duration_count).add(1.0);
```
Track the status codes of your responses!
```rust
let resp = compute_response();
metric!(responses{code=resp.status()}).add(1.0);
Ok(resp)
```
Now, run your app with `RUST_METRICS_PORT` set:
```console
$ RUST_METRICS_PORT=9898 cargo run
```
...and connect to see what's happening:
```console
$ curl localhost:9898
my_data_cap 1024
my_data_len 764
my_function_duration_count 6032
my_function_duration_sum 8.32
responses{code="200 OK"} 5443
responses{code="404 Not Found"} 587
responses{code="500 Internal Server Error"} 2
```
Your program can also call `epimetheus::query()` to inspect its own metrics.
## Features
* Multi-threaded OK! Everyone shares the same set of metrics.
* The format is prometheus-compatible. Point prometheus' watchful eye at
your program and get nice graphs.
* Updating metrics is fast (...mostly. See below.)
* The port number can be customised via the `RUST_METRICS_PORT` environment
variable.
* The code is very readable - under 200 sloc. [Take a
look!](https://docs.rs/epimetheus/latest/src/epimetheus/lib.rs.html)
* Public domain.
## Performance
* Updating an unlabelled metric (like `my_data_len` above) is fast (~500ns
uncontended, ~5us contended).
* Updating a labelled metric (like `responses` above) is slower (~1us
uncontended, ~10us contended).
* The HTTP server is extremely dumb and can only handle one client at a time;
typically this doesn't matter.
## Other stuff
Epimetheus is the brother of Prometheus, hence the crate's name.