Sha256: 7a495ae48fee2346d3c8cbd32750a45df09e2dad958de4349769fe38a8e457fc

Contents?: true

Size: 899 Bytes

Versions: 26

Compression:

Stored size: 899 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
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
prometheus-client-mmap-0.7.0.beta14 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta13 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta12 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta11 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta10 lib/prometheus/client/gauge.rb
prometheus-client-mmap-0.7.0.beta9 lib/prometheus/client/gauge.rb