class

Crometheus::Summary

Inherits Crometheus::Metric / Reference / Object

Summary is a metric type that keeps a running total of observations. Every time #observe is called, sum is incremented by the given value, and count is incremented by one.

Quantiles are not currently supported.

require "crometheus/summary"

cargo_weight = Crometheus::Summary.new(
  :cargo_weight, "Weight of all boxes")
cargo_weight.observe 29.0
cargo_weight.observe 12.0
cargo_weight.observe 10.0

mean_weight = cargo_weight.sum / cargo_weight.count # => 17.0

Class methods

type

Returns Type::Summary. See Metric.type.

Source
valid_label?(label : Symbol)

In addition to the standard Metric.valid_label? behavior, returns false if a label is :quantile. Histograms reserve this label for exporting quantiles (currently unsupported by Crometheus).

Source

Instance methods

count

The total number of observations.

Source
measure_runtime

Yields to the block, then passes the block's runtime to #observe.

Source
observe(value : Int8 | Int16 | Int32 | Int64 | Int128 | Float32 | Float64)

Increments count by one and sum by value.

Source
reset

Sets count and sum to 0.0.

Source
samples

Yields two samples, one for count and one for sum. See Metric#samples.

Source
sum

The sum of all observed values.

Source