Integrated: metrics: add library

Erik Helin ehelin at
Wed May 12 07:03:30 UTC 2021

On Tue, 11 May 2021 18:32:17 GMT, Erik Helin <ehelin at> wrote:

> Hi all,
> please review this patch that adds the new `metrics` library. The metrics library can be used to collect runtime metrics, such as the number of HTTP requests or the number of bot runs. The library is designed according to the [Prometheus library guide]( and currently features the two Prometheus types [gauge]( and [counter]( The library is designed to allow it to be extended with the [histogram]( and [summary]( types if we find a need for them.
> The `Counter` and `Gauge` types are designed to be thread-safe and should typically be stored in a `private final static` variable in a classes (similar to how one might store a `Logger` instance). A minimal `Counter` example looks like:
> class Example {
>     private static final Counter counter ="test").register();
> }
> I won't go into details here on how Prometheus naming and labelling works, please see the Prometheus [documentation]( for those concepts. The goal is that library should be fairly self-explanatory for someone with an understanding of how Prometheus works. Note though that the `metrics` library itself is not tied to Prometheus in any way, it only supports the collection of runtime metrics. It is however designed to make it easy to write a Prometheus exporter, something I will show in a follow-up patch. 
> I also added a bunch of unit tests for the new library.
> Thanks,
> Erik

This pull request has now been integrated.

Changeset: 537acafc
Author:    Erik Helin <ehelin at>
Stats:     1234 lines in 34 files changed: 1228 ins; 1 del; 5 mod

metrics: add library

Reviewed-by: erikj



More information about the skara-dev mailing list