Sha256: ef1a5bde3cf2b0479abb45090454cbed4caa6a71e5c20b6ab832b429c0c5c798
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
# encoding: UTF-8 require 'prometheus/client/metric' module Prometheus module Client # A Gauge is a metric that exposes merely an instantaneous value or some # snapshot thereof. class Gauge < Metric def type :gauge end # Sets the value for the given label set def set(labels, value) unless value.is_a?(Numeric) raise ArgumentError, 'value must be a number' end @values[label_set_for(labels)] = value.to_f end # 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.) def increment(labels = {}, by = 1) label_set = label_set_for(labels) synchronize do @values[label_set] ||= 0 @values[label_set] += by end end # 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.) def decrement(labels = {}, by = 1) label_set = label_set_for(labels) synchronize do @values[label_set] ||= 0 @values[label_set] -= by end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prometheus-client-0.9.0 | lib/prometheus/client/gauge.rb |
prometheus-client-0.8.0 | lib/prometheus/client/gauge.rb |