class Prometheus::Client::Gauge

A Gauge is a metric that exposes merely an instantaneous value or some snapshot thereof.

Public Instance Methods

decrement(by: 1, labels: {}) click to toggle source

Decrements Gauge value by 1 or subtracts the given value from the Gauge. (The value can be negative, resulting in a increase of the Gauge.)

# File lib/prometheus/client/gauge.rb, line 32
def decrement(by: 1, labels: {})
  label_set = label_set_for(labels)
  @store.increment(labels: label_set, by: -by)
end
increment(by: 1, labels: {}) click to toggle source

Increments Gauge value by 1 or adds the given value to the Gauge. (The value can be negative, resulting in a decrease of the Gauge.)

# File lib/prometheus/client/gauge.rb, line 25
def increment(by: 1, labels: {})
  label_set = label_set_for(labels)
  @store.increment(labels: label_set, by: by)
end
set(value, labels: {}) click to toggle source

Sets the value for the given label set

# File lib/prometheus/client/gauge.rb, line 15
def set(value, labels: {})
  unless value.is_a?(Numeric)
    raise ArgumentError, 'value must be a number'
  end

  @store.set(labels: label_set_for(labels), val: value)
end
type() click to toggle source
# File lib/prometheus/client/gauge.rb, line 10
def type
  :gauge
end