Class: Prometheus::Client::Summary

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

Instance Method Summary collapse

Methods inherited from Metric

#initialize, #to_json

Constructor Details

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

Instance Method Details

#add(labels, value) ⇒ Object

Records a given value.



12
13
14
15
# File 'lib/prometheus/client/summary.rb', line 12

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



18
19
20
21
22
23
24
25
26
# File 'lib/prometheus/client/summary.rb', line 18

def get(labels = {})
  synchronize do
    estimator = @values[label_set_for(labels)]
    estimator.invariants.inject({}) do |memo, invariant|
      memo[invariant.quantile] = estimator.query(invariant.quantile)
      memo
    end
  end
end

#typeObject



7
8
9
# File 'lib/prometheus/client/summary.rb', line 7

def type
  :histogram
end