Class: Prometheus::Client::Summary

Inherits:
Metric
  • Object
show all
Defined in:
lib/prometheus/client/summary.rb

Overview

Summary is an accumulator for samples. It captures Numeric data and provides an efficient quantile calculation mechanism.

Defined Under Namespace

Classes: Value

Instance Attribute Summary

Attributes inherited from Metric

#base_labels, #docstring, #name

Instance Method Summary collapse

Methods inherited from Metric

#initialize

Constructor Details

This class inherits a constructor from Prometheus::Client::Metric

Instance Method Details

#add(labels, value) ⇒ Object

Records a given value.



29
30
31
32
# File 'lib/prometheus/client/summary.rb', line 29

def add(labels, value)
  label_set = label_set_for(labels)
  synchronize { @values[label_set].observe(value) }
end

#get(labels = {}) ⇒ Object

Returns the value for the given label set



35
36
37
38
39
40
41
# File 'lib/prometheus/client/summary.rb', line 35

def get(labels = {})
  @validator.valid?(labels)

  synchronize do
    Value.new(@values[labels])
  end
end

#typeObject



24
25
26
# File 'lib/prometheus/client/summary.rb', line 24

def type
  :summary
end

#valuesObject

Returns all label sets with their values



44
45
46
47
48
49
50
# File 'lib/prometheus/client/summary.rb', line 44

def values
  synchronize do
    @values.each_with_object({}) do |(labels, value), memo|
      memo[labels] = Value.new(value)
    end
  end
end