Class: Yabeda::Gauge

Inherits:
Metric show all
Defined in:
lib/yabeda/gauge.rb

Overview

Arbitrary value, can be changed in both sides

Instance Attribute Summary

Attributes inherited from Metric

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

Instance Method Summary collapse

Methods inherited from Metric

#get, #initialize, #values

Constructor Details

This class inherits a constructor from Yabeda::Metric

Instance Method Details

#decrement(tags, by: 1) ⇒ Object


19
20
21
# File 'lib/yabeda/gauge.rb', line 19

def decrement(tags, by: 1)
  set(tags, get(tags).to_i - by)
end

#increment(tags, by: 1) ⇒ Object


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

def increment(tags, by: 1)
  set(tags, get(tags).to_i + by)
end

#set(tags, value) ⇒ Object


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

def set(tags, value)
  all_tags = ::Yabeda::Tags.build(tags)
  values[all_tags] = value
  ::Yabeda.adapters.each do |_, adapter|
    adapter.perform_gauge_set!(self, all_tags, value)
  end
  value
end