Skip to content

Prometheus client with counters, gauges and histograms implemented using atomics

License

Notifications You must be signed in to change notification settings

shortishly/metrics

Repository files navigation


Test Coverage edoc Erlang/OTP Apache-2.0

Metrics

main

An Erlang/OTP Prometheus client application that providing the following metric types:

  • Counter. A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart.

  • Gauge. A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.

  • Histogram. A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values.

Metrics are exposed using the text based exposition format via HTTP using Cowboy.

Internally metrics uses atomics and counters available since OTP21.2.

Overview

The data model follows that of Prometheus. Every time series is uniquely identified by its metric name and optional key-value pairs called labels.

The API has a single arity map parameter. While counters, gauges or histograms are not initialised before use, once a metric name has been used it cannot be used by another type.

1> metrics:counter(#{name => errors, value => 6}).
ok

2> metrics:value(#{name => errors}).
6

3> metrics:counter(#{name => requests_served,
                   label => #{channel => mobile},
                   delta => 11}).
ok

4> metrics:value(#{name => requests_served,
                   label => #{channel => mobile}}).
11


5> metrics:counter(#{name => requests_served,
                   label => #{channel => desktop},
                   delta => 56}).
ok

6> metrics:value(#{name => requests_served,
                   label => #{channel => desktop}}).
56

About

Prometheus client with counters, gauges and histograms implemented using atomics

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published