class Prometheus::Client::Histogram
A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values.
Constants
- DEFAULT_BUCKETS
DEFAULT_BUCKETS are the default Histogram buckets. The default buckets are tailored to broadly measure the response time (in seconds) of a network service. (From DefBuckets client_golang)
Public Class Methods
new(name, docstring, base_labels = {}, buckets = DEFAULT_BUCKETS)
click to toggle source
Offer a way to manually specify buckets
Calls superclass method
# File lib/prometheus/client/histogram.rb, line 51 def initialize(name, docstring, base_labels = {}, buckets = DEFAULT_BUCKETS) raise ArgumentError, 'Unsorted buckets, typo?' unless sorted? buckets @buckets = buckets super(name, docstring, base_labels) end
Public Instance Methods
observe(labels, value)
click to toggle source
# File lib/prometheus/client/histogram.rb, line 63 def observe(labels, value) label_set = label_set_for(labels) synchronize { @values[label_set].observe(value) } end
type()
click to toggle source
# File lib/prometheus/client/histogram.rb, line 59 def type :histogram end
Private Instance Methods
default(labels)
click to toggle source
# File lib/prometheus/client/histogram.rb, line 70 def default(labels) # TODO: default function needs to know key of hash info (label names and values) Value.new(type, @name, labels, @buckets) end
sorted?(bucket)
click to toggle source
# File lib/prometheus/client/histogram.rb, line 75 def sorted?(bucket) bucket.each_cons(2).all? { |i, j| i <= j } end