class Crometheus::Summary

Overview

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

Defined in:

crometheus/summary.cr

Class Method Summary

Instance Method Summary

Instance methods inherited from class Crometheus::Metric

docstring : String docstring, name : Symbol name, samples(&block : Sample -> Nil) : Nil samples

Constructor methods inherited from class Crometheus::Metric

new(name : Symbol, docstring : String, register_with : Crometheus::Registry | Nil = Crometheus.default_registry) new

Class methods inherited from class Crometheus::Metric

type type, valid_label?(label : Symbol) : Bool valid_label?

Class Method Detail

def self.type #

Returns Type::Summary. See Metric.type.


[View source]
def self.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).


[View source]

Instance Method Detail

def count : Float64 #

The total number of observations.


[View source]
def measure_runtime(&) #

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


[View source]
def observe(value : Int8 | Int16 | Int32 | Int64 | Int128 | Float32 | Float64) #

Increments #count by one and #sum by value.


[View source]
def reset #

Sets #count and #sum to 0.0.


[View source]
def samples(&block : Sample -> Nil) : Nil #

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


[View source]
def sum : Float64 #

The sum of all observed values.


[View source]