Class: Prometheus::Client::Gauge
- Defined in:
- lib/prometheus/client/gauge.rb
Overview
A Gauge is a metric that exposes merely an instantaneous value or some snapshot thereof.
Instance Attribute Summary
Attributes inherited from Metric
#base_labels, #docstring, #name
Instance Method Summary collapse
- #decrement(labels, value) ⇒ Object
- #default(labels) ⇒ Object
- #increment(labels, value) ⇒ Object
-
#initialize(name, docstring, base_labels = {}, multiprocess_mode = :all) ⇒ Gauge
constructor
A new instance of Gauge.
-
#set(labels, value) ⇒ Object
Sets the value for the given label set.
- #type ⇒ Object
Methods inherited from Metric
Methods included from UsesValueType
Constructor Details
#initialize(name, docstring, base_labels = {}, multiprocess_mode = :all) ⇒ Gauge
Returns a new instance of Gauge.
10 11 12 13 14 15 16 |
# File 'lib/prometheus/client/gauge.rb', line 10 def initialize(name, docstring, base_labels = {}, multiprocess_mode=:all) super(name, docstring, base_labels) if value_class.multiprocess and ![:min, :max, :livesum, :liveall, :all].include?(multiprocess_mode) raise ArgumentError, 'Invalid multiprocess mode: ' + multiprocess_mode end @multiprocess_mode = multiprocess_mode end |
Instance Method Details
#decrement(labels, value) ⇒ Object
35 36 37 |
# File 'lib/prometheus/client/gauge.rb', line 35 def decrement(labels, value) @values[label_set_for(labels)].decrement(value) end |
#default(labels) ⇒ Object
22 23 24 |
# File 'lib/prometheus/client/gauge.rb', line 22 def default(labels) value_object(type, @name, @name, labels, @multiprocess_mode) end |
#increment(labels, value) ⇒ Object
31 32 33 |
# File 'lib/prometheus/client/gauge.rb', line 31 def increment(labels, value) @values[label_set_for(labels)].increment(value) end |
#set(labels, value) ⇒ Object
Sets the value for the given label set
27 28 29 |
# File 'lib/prometheus/client/gauge.rb', line 27 def set(labels, value) @values[label_set_for(labels)].set(value) end |
#type ⇒ Object
18 19 20 |
# File 'lib/prometheus/client/gauge.rb', line 18 def type :gauge end |