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

#docstring, #labels, #name, #preset_labels

Instance Method Summary collapse

Methods inherited from Metric

#get, #init_label_set, #initialize, #values, #with_labels

Constructor Details

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

Instance Method Details

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

Raises:

  • (ArgumentError)


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

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

  label_set = label_set_for(labels)
  @store.increment(labels: label_set, by: by)
end

#typeObject



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

def type
  :counter
end