lib/prometheus/client/registry.rb in prometheus-client-0.5.0 vs lib/prometheus/client/registry.rb in prometheus-client-0.6.0
- old
+ new
@@ -3,10 +3,11 @@
require 'thread'
require 'prometheus/client/counter'
require 'prometheus/client/summary'
require 'prometheus/client/gauge'
+require 'prometheus/client/histogram'
module Prometheus
module Client
# Registry
class Registry
@@ -20,11 +21,11 @@
def register(metric)
name = metric.name
@mutex.synchronize do
if exist?(name.to_sym)
- fail AlreadyRegisteredError, "#{name} has already been registered"
+ raise AlreadyRegisteredError, "#{name} has already been registered"
else
@metrics[name.to_sym] = metric
end
end
@@ -39,9 +40,14 @@
register(Summary.new(name, docstring, base_labels))
end
def gauge(name, docstring, base_labels = {})
register(Gauge.new(name, docstring, base_labels))
+ end
+
+ def histogram(name, docstring, base_labels = {},
+ buckets = Histogram::DEFAULT_BUCKETS)
+ register(Histogram.new(name, docstring, base_labels, buckets))
end
def exist?(name)
@metrics.key?(name)
end