Sha256: 27e464edad255686feeec1e466868f9e2840e8b139e5fbe7cf6533294f3a360a

Contents?: true

Size: 529 Bytes

Versions: 5

Compression:

Stored size: 529 Bytes

Contents

# encoding: UTF-8

require 'prometheus/client/metric'

module Prometheus
  module Client
    # Counter is a metric that exposes merely a sum or tally of things.
    class Counter < Metric
      def type
        :counter
      end

      def increment(labels = {}, by = 1)
        raise ArgumentError, 'increment must be a non-negative number' if by < 0

        label_set = label_set_for(labels)
        synchronize { @values[label_set] += by }
      end

      private

      def default
        0.0
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
prometheus-client-0.9.0 lib/prometheus/client/counter.rb
prometheus-client-0.8.0 lib/prometheus/client/counter.rb
prometheus-client-0.7.1 lib/prometheus/client/counter.rb
prometheus-client-0.7.0 lib/prometheus/client/counter.rb
prometheus-client-0.7.0.pre.rc.1 lib/prometheus/client/counter.rb