Behaviours: prometheus_collector, prometheus_metric.
A Histogram tracks the size and number of events in buckets. You can use Histograms for aggregatable calculation of quantiles.
Example use cases for Histograms:Histogram expects buckets key in a metric spec. Buckets can be:
- a list of numbers in increasing order;
- :default;
- {:linear, start, step, count};
- {:exponential, start, step, count}
-module(example_instrumenter).
setup() ->
prometheus_histogram:declare([{name, http_request_duration_milliseconds},
{labels, [method]},
{buckets, [100, 300, 500, 750, 1000]},
{help, "Http Request execution time."}]).
instrument(Time, Method) ->
%% Time must be in native units, otherwise duration_unit must be false
prometheus_histogram:observe(http_request_duration_milliseconds,
[Method], Time).
| buckets/1 | Equivalent to buckets(default, Name, []).
|
| buckets/2 | Equivalent to buckets(default, Name, LabelValues).
|
| buckets/3 | Returns buckets of the histogram identified by Registry, Name
and LabelValues. |
| declare/1 | Creates a histogram using Spec. |
| deregister/1 | Equivalent to deregister(default, Name).
|
| deregister/2 |
Removes all histogram series with name Name and
removes Metric Family from Registry. |
| new/1 | Creates a histogram using Spec. |
| observe/2 | Equivalent to observe(default, Name, [], Value).
|
| observe/3 | Equivalent to observe(default, Name, LabelValues, Value).
|
| observe/4 | Observes the given Value. |
| observe_duration/2 | Equivalent to observe_duration(default, Name, [], Fun).
|
| observe_duration/3 | Equivalent to observe_duration(default, Name, LabelValues, Fun).
|
| observe_duration/4 | Tracks the amount of time spent executing Fun. |
| remove/1 | Equivalent to remove(default, Name, []).
|
| remove/2 | Equivalent to remove(default, Name, LabelValues).
|
| remove/3 | Removes histogram series identified by Registry, Name
and LabelValues. |
| reset/1 | Equivalent to reset(default, Name, []).
|
| reset/2 | Equivalent to reset(default, Name, LabelValues).
|
| reset/3 | Resets the value of the histogram identified by Registry, Name
and LabelValues. |
| value/1 | Equivalent to value(default, Name, []).
|
| value/2 | Equivalent to value(default, Name, LabelValues).
|
| value/3 | Returns the value of the histogram identified by Registry, Name
and LabelValues. |
| values/2 |
buckets(Name) -> any()
Equivalent to buckets(default, Name, []).
buckets(Name, LabelValues) -> any()
Equivalent to buckets(default, Name, LabelValues).
buckets(Registry, Name, LabelValues) -> any()
Returns buckets of the histogram identified by Registry, Name
and LabelValues.
declare(Spec) -> any()
Creates a histogram using Spec.
If a histogram with the same Spec exists returns false.
Raises {missing_metric_spec_key, Key, Spec} error if required Soec key
is missing.
Raises {invalid_metric_name, Name, Message} error if metric Name
is invalid.
Raises {invalid_metric_help, Help, Message} error if metric Help
is invalid.
Raises {invalid_metric_labels, Labels, Message} error if Labels
isn't a list.
Raises {invalid_label_name, Name, Message} error if Name isn't a valid
label name.
Raises {invalid_value_error, Value, MessagE} error if duration_unit is
unknown or doesn't match metric name.
{no_buckets, Buckets} error if Buckets are missing,
not a list, empty list or not known buckets spec.{invalid_buckets, Buckets, Message} error if Buckets
aren't in increasing order.{invalid_bound, Bound} error if Bound isn't a number.
deregister(Name) -> any()
Equivalent to deregister(default, Name).
deregister(Registry, Name) -> any()
Removes all histogram series with name Name and
removes Metric Family from Registry.
After this call new/1 for Name and Registry will succeed.
{true, _} if Name was a registered histogram.
Otherwise returns {false, _}.
new(Spec) -> any()
Creates a histogram using Spec.
Raises {missing_metric_spec_key, Key, Spec} error if required Soec key
is missing.
Raises {invalid_metric_name, Name, Message} error if metric Name
is invalid.
Raises {invalid_metric_help, Help, Message} error if metric Help
is invalid.
Raises {invalid_metric_labels, Labels, Message} error if Labels
isn't a list.
Raises {invalid_label_name, Name, Message} error if Name isn't a valid
label name.
Raises {invalid_value_error, Value, Message} error if duration_unit is
unknown or doesn't match metric name.
Raises {mf_already_exists, {Registry, Name}, Message} error if a histogram
with the same Spec already exists.
{no_buckets, Buckets} error if Buckets are missing,
not a list, empty list or not known buckets spec.{invalid_buckets, Buckets, Message} error if Buckets
aren't in increasing order.{invalid_bound, Bound} error if Bound isn't a number.
observe(Name, Value) -> any()
Equivalent to observe(default, Name, [], Value).
observe(Name, LabelValues, Value) -> any()
Equivalent to observe(default, Name, LabelValues, Value).
observe(Registry, Name, LabelValues, Value) -> any()
Observes the given Value.
{invalid_value, Value, Message} if Value
isn't an integer.{unknown_metric, Registry, Name} error if histogram with named
Name can't be found in Registry.{invalid_metric_arity, Present, Expected} error if labels count
mismatch.
observe_duration(Name, Fun) -> any()
Equivalent to observe_duration(default, Name, [], Fun).
observe_duration(Name, LabelValues, Fun) -> any()
Equivalent to observe_duration(default, Name, LabelValues, Fun).
observe_duration(Registry, Name, LabelValues, Fun) -> any()
Tracks the amount of time spent executing Fun.
{unknown_metric, Registry, Name} error if histogram with named
Name can't be found in Registry.{invalid_metric_arity, Present, Expected} error if labels count
mismatch.
Raises {invalid_value, Value, Message} if Fun
isn't a function.remove(Name) -> any()
Equivalent to remove(default, Name, []).
remove(Name, LabelValues) -> any()
Equivalent to remove(default, Name, LabelValues).
remove(Registry, Name, LabelValues) -> any()
Removes histogram series identified by Registry, Name
and LabelValues.
{unknown_metric, Registry, Name} error if histogram with name
Name can't be found in Registry.{invalid_metric_arity, Present, Expected} error if labels count
mismatch.
reset(Name) -> any()
Equivalent to reset(default, Name, []).
reset(Name, LabelValues) -> any()
Equivalent to reset(default, Name, LabelValues).
reset(Registry, Name, LabelValues) -> any()
Resets the value of the histogram identified by Registry, Name
and LabelValues.
{unknown_metric, Registry, Name} error if histogram with name
Name can't be found in Registry.{invalid_metric_arity, Present, Expected} error if labels count
mismatch.
value(Name) -> any()
Equivalent to value(default, Name, []).
value(Name, LabelValues) -> any()
Equivalent to value(default, Name, LabelValues).
value(Registry, Name, LabelValues) -> any()
Returns the value of the histogram identified by Registry, Name
and LabelValues. If there is no histogram for LabelValues,
returns undefined.
If duration unit set, sum will be converted to the duration unit. Read more here.
Raises{unknown_metric, Registry, Name} error if histogram named Name
can't be found in Registry.{invalid_metric_arity, Present, Expected} error if labels count
mismatch.
values(Registry, Name) -> any()
Generated by EDoc