themis/histogram

Types

pub type HistogramError {
  MetricError(metric.MetricError)
  StoreError(store.StoreError)
  InvalidBucketValue
  CannotObserveNaN
  LabelError(label.LabelError)
}

Constructors

  • MetricError(metric.MetricError)
  • StoreError(store.StoreError)
  • InvalidBucketValue
  • CannotObserveNaN
  • LabelError(label.LabelError)

Functions

pub fn new(
  store store: Store,
  name name: String,
  description description: String,
  buckets buckets: Set(Number),
) -> Result(Nil, HistogramError)

Registers a new histogram metric to the store. The “Buckets” argument is a set of histogram buckets “le” values, as described here https://prometheus.io/docs/practices/histograms/ Will return an error if the metric name is invalid, already used, or if any of the buckets have an invalid value (“PosInf, NegInf, NaN”)

pub fn observe(
  store store: Store,
  name name: String,
  labels labels: Dict(String, String),
  value value: Number,
) -> Result(Nil, HistogramError)

Records a datapoint into the histogram 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 number.NaN

pub fn print(
  store store: Store,
) -> Result(String, HistogramError)

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

Search Document