themis/counter

Types

pub type CounterError {
  MetricError(metric.MetricError)
  StoreError(store.StoreError)
  InvalidIncrement(value: Number)
  NegativeIncrement
  CounterNameShouldEndWithTotal
  LabelError(label.LabelError)
}

Constructors

  • MetricError(metric.MetricError)
  • StoreError(store.StoreError)
  • InvalidIncrement(value: Number)
  • NegativeIncrement
  • CounterNameShouldEndWithTotal
  • LabelError(label.LabelError)

Functions

pub fn increment(
  name name: String,
  labels labels: Dict(String, String),
) -> Result(Nil, CounterError)

Increments a counter metric for the given metric name. Will return an error if the name is invalid, not a registered metric or not of the correct metric type. Will return an error if any of the labels have an invalid key.

pub fn increment_by(
  name name: String,
  labels labels: Dict(String, String),
  value value: Number,
) -> Result(Nil, CounterError)

Increments a counter metric for the given metric name. Will return an error if the name is invalid, not a registered metric or not of the correct metric type. Will return an error if any of the labels have an invalid key. Will return an error if the value is NaN, PosInf or NegInf.

pub fn new(
  name name: String,
  description description: String,
) -> Result(Nil, CounterError)

Registers a new counter metric to the store. Counter metric names must end with _total. Will return an error if the metric name is invalid or already used by another metric.

pub fn print() -> Result(String, CounterError)

Formats all counter metrics in the store as a Prometheus-compatible text string.

Search Document