Class: Prometheus::Client::Counter

Inherits:
Metric
  • Object
show all
Defined in:
lib/prometheus/client/counter.rb

Overview

Counter is a metric that exposes merely a sum or tally of things.

Instance Attribute Summary

Attributes inherited from Metric

#base_labels, #docstring, #name

Instance Method Summary collapse

Methods inherited from Metric

#get, #initialize, #values

Constructor Details

This class inherits a constructor from Prometheus::Client::Metric

Instance Method Details

#increment(labels = {}, by = 1) ⇒ Object



13
14
15
16
17
18
# File 'lib/prometheus/client/counter.rb', line 13

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

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

#typeObject



9
10
11
# File 'lib/prometheus/client/counter.rb', line 9

def type
  :counter
end