class Prometheus::Client::Registry
Public Class Methods
new()
click to toggle source
# File lib/prometheus/client/registry.rb, line 16 def initialize @metrics = {} @mutex = Mutex.new end
Public Instance Methods
counter(name, docstring:, labels: [], preset_labels: {}, store_settings: {})
click to toggle source
# File lib/prometheus/client/registry.rb, line 40 def counter(name, docstring:, labels: [], preset_labels: {}, store_settings: {}) register(Counter.new(name, docstring: docstring, labels: labels, preset_labels: preset_labels, store_settings: store_settings)) end
exist?(name)
click to toggle source
# File lib/prometheus/client/registry.rb, line 75 def exist?(name) @metrics.key?(name) end
gauge(name, docstring:, labels: [], preset_labels: {}, store_settings: {})
click to toggle source
# File lib/prometheus/client/registry.rb, line 56 def gauge(name, docstring:, labels: [], preset_labels: {}, store_settings: {}) register(Gauge.new(name, docstring: docstring, labels: labels, preset_labels: preset_labels, store_settings: store_settings)) end
get(name)
click to toggle source
# File lib/prometheus/client/registry.rb, line 79 def get(name) @metrics[name.to_sym] end
histogram(name, docstring:, labels: [], preset_labels: {}, buckets: Histogram::DEFAULT_BUCKETS, store_settings: {})
click to toggle source
# File lib/prometheus/client/registry.rb, line 64 def histogram(name, docstring:, labels: [], preset_labels: {}, buckets: Histogram::DEFAULT_BUCKETS, store_settings: {}) register(Histogram.new(name, docstring: docstring, labels: labels, preset_labels: preset_labels, buckets: buckets, store_settings: store_settings)) end
metrics()
click to toggle source
# File lib/prometheus/client/registry.rb, line 83 def metrics @metrics.values end
register(metric)
click to toggle source
# File lib/prometheus/client/registry.rb, line 21 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:, labels: [], preset_labels: {}, store_settings: {})
click to toggle source
# File lib/prometheus/client/registry.rb, line 48 def summary(name, docstring:, labels: [], preset_labels: {}, store_settings: {}) register(Summary.new(name, docstring: docstring, labels: labels, preset_labels: preset_labels, store_settings: store_settings)) end
unregister(name)
click to toggle source
# File lib/prometheus/client/registry.rb, line 34 def unregister(name) @mutex.synchronize do @metrics.delete(name.to_sym) end end