class Prometheus::Client::Histogram::Value

Value represents the state of a Histogram at a given point.

Attributes

sum[RW]
total[RW]
total_inf[RW]

Public Class Methods

new(type, name, labels, buckets) click to toggle source
# File lib/prometheus/client/histogram.rb, line 15
def initialize(type, name, labels, buckets)
  @sum = value_object(type, name, "#{name}_sum", labels)
  @total = value_object(type, name, "#{name}_count", labels)
  @total_inf = value_object(type, name, "#{name}_bucket", labels.merge(le: "+Inf"))

  buckets.each do |bucket|
    self[bucket] = value_object(type, name, "#{name}_bucket", labels.merge(le: bucket.to_s))
  end
end

Public Instance Methods

get() click to toggle source
# File lib/prometheus/client/histogram.rb, line 35
def get()
  hash = {}
  each_key do |bucket|
    hash[bucket] = self[bucket].get()
  end
  hash
end
observe(value) click to toggle source
# File lib/prometheus/client/histogram.rb, line 25
def observe(value)
  @sum.increment(value)
  @total.increment()
  @total_inf.increment()

  each_key do |bucket|
    self[bucket].increment() if value <= bucket
  end
end