RFR: metrics: add library [v2]
Erik Helin
ehelin at openjdk.java.net
Wed May 12 07:03:29 UTC 2021
> 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](https://prometheus.io/docs/instrumenting/writing_clientlibs/) and currently features the two Prometheus types [gauge](https://prometheus.io/docs/concepts/metric_types/#gauge) and [counter](https://prometheus.io/docs/concepts/metric_types/#counter). The library is designed to allow it to be extended with the [histogram](https://prometheus.io/docs/concepts/metric_types/#histogram) and [summary](https://prometheus.io/docs/concepts/metric_types/#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 = Counter.name("test").register();
> }
>
>
> I won't go into details here on how Prometheus naming and labelling works, please see the Prometheus [documentation](https://prometheus.io/docs/introduction/overview/) 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
Erik Helin has updated the pull request incrementally with one additional commit since the last revision:
Reviewer feedback
-------------
Changes:
- all: https://git.openjdk.java.net/skara/pull/1148/files
- new: https://git.openjdk.java.net/skara/pull/1148/files/38e0ee00..35bb1235
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=skara&pr=1148&range=01
- incr: https://webrevs.openjdk.java.net/?repo=skara&pr=1148&range=00-01
Stats: 2 lines in 2 files changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.java.net/skara/pull/1148.diff
Fetch: git fetch https://git.openjdk.java.net/skara pull/1148/head:pull/1148
PR: https://git.openjdk.java.net/skara/pull/1148
More information about the skara-dev
mailing list