Sha256: 17e84ebaaa45f43cf70f802a5c33b898eeecf56923a31ec9ed5896349c68bedc

Contents?: true

Size: 582 Bytes

Versions: 214

Compression:

Stored size: 582 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].increment(by) }
      end

      private

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

Version data entries

214 entries across 214 versions & 2 rubygems

Version Path
prometheus-client-mmap-1.1.2 lib/prometheus/client/counter.rb
prometheus-client-mmap-1.1.2-x86_64-linux lib/prometheus/client/counter.rb
prometheus-client-mmap-1.1.2-x86_64-darwin lib/prometheus/client/counter.rb
prometheus-client-mmap-1.1.2-arm64-darwin lib/prometheus/client/counter.rb
prometheus-client-mmap-1.1.2-aarch64-linux lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.6 lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.6-x86_64-linux-musl lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.6-x86_64-linux-gnu lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.6-x86_64-darwin lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.6-arm64-darwin lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.6-aarch64-linux-musl lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.6-aarch64-linux-gnu lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.5 lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.5-x86_64-linux-musl lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.5-x86_64-linux-gnu lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.5-x86_64-darwin lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.5-arm64-darwin lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.5-aarch64-linux-musl lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.5-aarch64-linux-gnu lib/prometheus/client/counter.rb
prometheus-client-mmap-1.2.4 lib/prometheus/client/counter.rb