Sha256: ce14d00bd5212923f2918440788cafd2f4a6068dd7fcc30ccb858912b0a0d8f9

Contents?: true

Size: 900 Bytes

Versions: 8

Compression:

Stored size: 900 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 ValueClass.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)
        ValueClass.new(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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
prometheus-client-mmap-0.7.0.beta8 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta7 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta6 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta5 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta4 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta3 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta2 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta1 lib/prometheus/client/gauge.rb