View Source prometheus_metric behaviour (prometheus v5.0.0)

This module provides functions and types for managing Prometheus metrics in Erlang.

It includes functionality for inserting, deregistering, and checking metrics, as well as handling metric labels and data.

Summary

Types

Metric counter type

Metric duration unit type

Metric gauge type

Metric help type

Metric histogram type

Metric labels type

Metric name type

Metric specification type

Metric summary type

Metric value type

Callbacks

Inserts a new metric function into the table.

Inserts a new metric function into the table, fails if it already exists.

Removes a metric function by name.

Removes a metric function by name and label values.

Removes a metric function by registry, name, and label values.

Resets a metric function by name.

Resets a metric function by name and label values.

Resets a metric function by registry, name, and label values.

Sets the default metric function for the module.

Gets the value of a metric function by name.

Gets the value of a metric function by name and label values.

Gets the value of a metric function by registry, name, and label values.

Types

counter_value()

-type counter_value() :: number().

Metric counter type

duration_unit()

-type duration_unit() :: prometheus_time:duration_unit().

Metric duration unit type

gauge_value()

-type gauge_value() :: number().

Metric gauge type

help()

-type help() :: binary() | nonempty_string().

Metric help type

histogram_value()

-type histogram_value() :: {Buckets :: [number(), ...], Sum :: number()}.

Metric histogram type

labels()

-type labels() :: [name()].

Metric labels type

name()

-type name() :: atom() | binary() | nonempty_string() | iolist().

Metric name type

spec()

-type spec() :: proplists:proplist().

Metric specification type

summary_value()

-type summary_value() :: {Count :: number(), Sum :: number()}.

Metric summary type

value()

-type value() :: counter_value() | gauge_value() | summary_value() | histogram_value() | undefined.

Metric value type

Callbacks

declare(Spec)

-callback declare(Spec :: spec()) -> boolean().

Inserts a new metric function into the table.

new(Spec)

-callback new(Spec :: spec()) -> ok.

Inserts a new metric function into the table, fails if it already exists.

remove(Name)

-callback remove(Name :: name()) -> boolean() | no_return().

Removes a metric function by name.

remove(Name, LValues)

-callback remove(Name :: name(), LValues :: list()) -> boolean() | no_return().

Removes a metric function by name and label values.

remove(Registry, Name, LValues)

-callback remove(Registry, Name, LValues) -> boolean() | no_return()
                    when Registry :: prometheus_registry:registry(), Name :: name(), LValues :: list().

Removes a metric function by registry, name, and label values.

reset(Name)

-callback reset(Name :: name()) -> boolean() | no_return().

Resets a metric function by name.

reset(Name, LValues)

-callback reset(Name :: name(), LValues :: list()) -> boolean() | no_return().

Resets a metric function by name and label values.

reset(Registry, Name, LValues)

-callback reset(Registry, Name, LValues) -> boolean() | no_return()
                   when Registry :: prometheus_registry:registry(), Name :: name(), LValues :: list().

Resets a metric function by registry, name, and label values.

set_default(Registry, Name)

-callback set_default(Registry, Name) -> any()
                         when Registry :: prometheus_registry:registry(), Name :: name().

Sets the default metric function for the module.

value(Name)

-callback value(Name :: name()) -> value() | no_return().

Gets the value of a metric function by name.

value(Name, LValues)

-callback value(Name :: name(), LValues :: list()) -> value() | no_return().

Gets the value of a metric function by name and label values.

value(Registry, Name, LValues)

-callback value(Registry, Name, LValues) -> value() | no_return()
                   when Registry :: prometheus_registry:registry(), Name :: name(), LValues :: list().

Gets the value of a metric function by registry, name, and label values.