Class: Prometheus::Client::Summary

Inherits:
Metric
  • Object
show all
Extended by:
Gem::Deprecate
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

#get(labels = {}) ⇒ Object

Returns the value for the given label set


40
41
42
43
44
45
46
# File 'lib/prometheus/client/summary.rb', line 40

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

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

#observe(labels, value) ⇒ Object Also known as: add

Records a given value.


32
33
34
35
# File 'lib/prometheus/client/summary.rb', line 32

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

#typeObject


27
28
29
# File 'lib/prometheus/client/summary.rb', line 27

def type
  :summary
end

#valuesObject

Returns all label sets with their values


49
50
51
52
53
54
55
# File 'lib/prometheus/client/summary.rb', line 49

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