class Prometheus::Client::Registry
Public Class Methods
new()
click to toggle source
# File lib/prometheus/client/registry.rb, line 15 def initialize @metrics = {} @mutex = Mutex.new end
Public Instance Methods
counter(name, docstring, base_labels = {})
click to toggle source
# File lib/prometheus/client/registry.rb, line 33 def counter(name, docstring, base_labels = {}) register(Counter.new(name, docstring, base_labels)) end
exist?(name)
click to toggle source
# File lib/prometheus/client/registry.rb, line 50 def exist?(name) @metrics.key?(name) end
gauge(name, docstring, base_labels = {})
click to toggle source
# File lib/prometheus/client/registry.rb, line 41 def gauge(name, docstring, base_labels = {}) register(Gauge.new(name, docstring, base_labels)) end
get(name)
click to toggle source
# File lib/prometheus/client/registry.rb, line 54 def get(name) @metrics[name.to_sym] end
histogram(name, docstring, base_labels = {}, buckets = Histogram::DEFAULT_BUCKETS)
click to toggle source
# File lib/prometheus/client/registry.rb, line 45 def histogram(name, docstring, base_labels = {}, buckets = Histogram::DEFAULT_BUCKETS) register(Histogram.new(name, docstring, base_labels, buckets)) end
metrics()
click to toggle source
# File lib/prometheus/client/registry.rb, line 58 def metrics @metrics.values end
register(metric)
click to toggle source
# File lib/prometheus/client/registry.rb, line 20 def register(metric) name = metric.name @mutex.synchronize do if exist?(name.to_sym) raise AlreadyRegisteredError, "#{name} has already been registered" end @metrics[name.to_sym] = metric end metric end
summary(name, docstring, base_labels = {})
click to toggle source
# File lib/prometheus/client/registry.rb, line 37 def summary(name, docstring, base_labels = {}) register(Summary.new(name, docstring, base_labels)) end