Sha256: a162386aebc1083f5fd639384d62b319904a1db454194ceb1ac9847f82b2776a

Contents?: true

Size: 1001 Bytes

Versions: 37

Compression:

Stored size: 1001 Bytes

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 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

      def type
        :gauge
      end

      def default(labels)
        value_object(type, @name, @name, labels, @multiprocess_mode)
      end

      # Sets the value for the given label set
      def set(labels, value)
        @values[label_set_for(labels)].set(value)
      end

      def increment(labels, value)
        @values[label_set_for(labels)].increment(value)
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
prometheus-client-mmap-0.12.0 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.11.0 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.10.0 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.10 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.9 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.8 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.7 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.6 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.5 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.4 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.3 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.2 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.1 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.1.pre.rc.2 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.1.pre.rc.1 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.0.pre.rc.1 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.9.0 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta45.10 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta45.9 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta45.8 lib/prometheus/client/gauge.rb