Class: Yabeda::Counter

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

Overview

Growing-only counter

Instance Attribute Summary

Attributes inherited from Metric

#aggregation, #comment, #group, #name, #per, #tags, #unit

Instance Method Summary collapse

Methods inherited from Metric

#get, #initialize

Constructor Details

This class inherits a constructor from Yabeda::Metric

Instance Method Details

#increment(tags, by: 1) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/yabeda/counter.rb', line 6

def increment(tags, by: 1)
  all_tags = ::Yabeda::Tags.build(tags)
  values[all_tags] += by
  ::Yabeda.adapters.each do |_, adapter|
    adapter.perform_counter_increment!(self, all_tags, by)
  end
  values[all_tags]
end

#valuesObject



15
16
17
# File 'lib/yabeda/counter.rb', line 15

def values
  @values ||= Concurrent::Hash.new(0)
end