Hesione
A Prometheus client
Overview
There are a handful of other Prometheus clients for Rust already, but I decided to make another one. Rust has a lot of language features, and I felt like none of the existing implementations were truly using those to their advantage. With Hesione, traits are leveraged to make metric storage types pluggable, and a derive macro exists to make defining metrics and generating their collective outputs easy, among other things.
Also, my GitLab instance has GitHub and GitLab.com account sign-in enabled, so if you'd like to open issues or contribute code, please feel free to do so!
Features
- Rust things:
- Codegen that simplifies metric definitions
- Easy to instrument your code with
- Well-tested
- Process metrics
- Prometheus things:
- Counters
- Gauges
- Histograms
- Summaries
Examples
use ;
use Lazy;
use ;
/// The collection of metrics used by your program
/// A globally usable instance of the above structure
///
/// This isn't strictly necessary, although it will likely make instrumentation
/// much easier.
static METRICS: = new;
// Instrument your code by importing METRICS and modifying its fields:
METRICS.http_reqs.inc;
// You can also add labels when accessing a metric:
let labels = labels! .unwrap;
METRICS.http_reqs.inc;
// Call this method in your `/metrics` HTTP endpoint to generate the output:
let actual = METRICS.to_prometheus_lines;
// This is what the output will look like for this example:
let expected = concat!;
assert_eq!;
Contributing code
Be sure to run the .hooks/install.sh script after the first clone. The
post-merge hook will re-run this script to apply changes to the hooks, if there
are any. The pre-commit hook runs the formatter, linter (on deny warnings mode),
and the test suite. If you don't want to run hard-mode linter or the tests for
some reason (maybe you already did and just don't want to do it again
automatically, or are committing code-unrelated things), you can set the
SKIP_TESTS_PLEASE environment variable to anything.
License
This project is licensed under either of
-
Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
-
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.