Class: PrometheusClientAddons::Prometheus::Client::CustomCollector

Inherits:
Prometheus::Client::Metric
  • Object
show all
Defined in:
lib/prometheus_client_addons/prometheus/client/custom_collector.rb

Instance Method Summary collapse

Constructor Details

#initialize(name:, docstring:, base_labels: {}, &block) ⇒ CustomCollector

Returns a new instance of CustomCollector.



7
8
9
10
# File 'lib/prometheus_client_addons/prometheus/client/custom_collector.rb', line 7

def initialize(name:, docstring:, base_labels: {}, &block)
  @custom_collector = block
  super(name.to_sym, docstring, base_labels)
end

Instance Method Details

#get(labels = {}) ⇒ Object



12
13
14
# File 'lib/prometheus_client_addons/prometheus/client/custom_collector.rb', line 12

def get(labels = {})
  @custom_collector.call
end

#typeObject



20
21
22
# File 'lib/prometheus_client_addons/prometheus/client/custom_collector.rb', line 20

def type
  :gauge
end

#valuesObject



16
17
18
# File 'lib/prometheus_client_addons/prometheus/client/custom_collector.rb', line 16

def values
  { {} => @custom_collector.call }
end