themis

Types

A Store manages a collection of metrics, ensuring unique metric names.

pub type Store {
  Store(
    gauges: Dict(metric.MetricName, Metric(Gauge, Number)),
    counters: Dict(metric.MetricName, Metric(Counter, Number)),
  )
}

Constructors

  • Store(
      gauges: Dict(metric.MetricName, Metric(Gauge, Number)),
      counters: Dict(metric.MetricName, Metric(Counter, Number)),
    )

Represents possible errors that can occur when operating on the Store.

pub type StoreError {
  MetricNameAlreadyInUse
  MetricNameNotFound
  MetricError(metric.MetricError)
  LabelError(label.LabelError)
  CounterError(counter.CounterError)
}

Constructors

  • MetricNameAlreadyInUse

    Returned when attempting to create a metric with a name that’s already in use

  • MetricNameNotFound

    Returned when attempting to operate on a metric that doesn’t exist

  • MetricError(metric.MetricError)

    Wraps errors related to metric name validation

  • LabelError(label.LabelError)

    Wraps errors related to label validation

  • CounterError(counter.CounterError)

    Wraps errors related to counters

Functions

pub fn is_metric_name_used(
  store: Store,
  name: MetricName,
) -> Bool
pub fn new() -> Store

Creates a new empty metrics store.

pub fn print(metrics_store store: Store) -> String

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

Examples

let metrics_text = print(store)
// # HELP my_metric My first gauge
// # TYPE my_metric gauge
// my_metric{foo="bar"} 10
// my_metric{toto="tata",wibble="wobble"} +Inf
Search Document