View Source prometheus_buckets (prometheus v4.13.0)
Summary
Functions
Default histogram buckets.
Creates Count
buckets, where the lowest bucket has an upper bound of Start
and each following
bucket's upper bound is Factor
times the previous bucket's upper bound.
The returned list is meant to be used for the buckets
key of histogram constructors options.
Creates Count
buckets, each Width
wide, where the lowest bucket has an upper bound of Start
.
Histogram buckets constructor
Types
-type bucket_bound() :: number() | infinity.
-type buckets() :: [bucket_bound(), ...].
-type config() :: undefined | default | {linear, number(), number(), pos_integer()} | {exponential, number(), number(), pos_integer()} | buckets().
Histogram buckets configuration.
Setting the buckets
key of a histogram to
default
: will use the default bucketslinear
: will useStart
,Step
, andCount
to generate the buckets as inlinear/3
exponential
: will useStart
,Factor
, andCount
to generate the buckets as inexponential/3
You can also specify your own buckets if desired instead.
Functions
-spec default() -> buckets().
Default histogram buckets.
1> prometheus_buckets:default().
[0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10]
Please note these buckets are floats and represent seconds so you'll have to use
prometheus_histogramdobserve/3
or configure duration_unit
as seconds
.
-spec exponential(number(), number(), pos_integer()) -> buckets().
Creates Count
buckets, where the lowest bucket has an upper bound of Start
and each following
bucket's upper bound is Factor
times the previous bucket's upper bound.
The returned list is meant to be used for the buckets
key of histogram constructors options.
3> prometheus_buckets:exponential(100, 1.2, 3).
[100, 120, 144]
The function raises {invalid_value, Value, Message}
error if Count
isn't positive,
if Start
isn't positive, or if Factor
is less than or equals to 1.
-spec linear(number(), number(), pos_integer()) -> buckets().
Creates Count
buckets, each Width
wide, where the lowest bucket has an upper bound of Start
.
The returned list is meant to be used for the buckets
key of histogram constructors options.
2> prometheus_buckets:linear(10, 5, 6).
[10, 15, 20, 25, 30, 35]
The function raises {invalid_value, Value, Message}
error if Count
is zero or negative.
-spec new() -> buckets().
Histogram buckets constructor, returns default/0
plus infinity
Histogram buckets constructor
-spec position(buckets(), number()) -> pos_integer().