Class: Yabeda::TestAdapter
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- Yabeda::TestAdapter
- Includes:
- Singleton
- Defined in:
- lib/yabeda/test_adapter.rb
Overview
Fake monitoring system adapter that collects latest metric values for later inspection
Instance Attribute Summary collapse
-
#counters ⇒ Object
readonly
Returns the value of attribute counters.
-
#gauges ⇒ Object
readonly
Returns the value of attribute gauges.
-
#histograms ⇒ Object
readonly
Returns the value of attribute histograms.
-
#summaries ⇒ Object
readonly
Returns the value of attribute summaries.
Instance Method Summary collapse
-
#initialize ⇒ TestAdapter
constructor
rubocop:disable Metrics/AbcSize.
- #perform_counter_increment!(counter, tags, increment) ⇒ Object
- #perform_gauge_set!(gauge, tags, value) ⇒ Object
- #perform_histogram_measure!(histogram, tags, value) ⇒ Object
- #perform_summary_observe!(summary, tags, value) ⇒ Object
- #register_counter!(metric) ⇒ Object
- #register_gauge!(metric) ⇒ Object
- #register_histogram!(metric) ⇒ Object
- #register_summary!(metric) ⇒ Object
-
#reset! ⇒ Object
Call this method after every test example to quickly get blank state for the next test example.
Methods inherited from BaseAdapter
Constructor Details
#initialize ⇒ TestAdapter
rubocop:disable Metrics/AbcSize
15 16 17 18 19 20 21 |
# File 'lib/yabeda/test_adapter.rb', line 15 def initialize super @counters = Hash.new { |ch, ck| ch[ck] = Hash.new { |th, tk| th[tk] = 0 } } @gauges = Hash.new { |gh, gk| gh[gk] = Hash.new { |th, tk| th[tk] = nil } } @histograms = Hash.new { |hh, hk| hh[hk] = Hash.new { |th, tk| th[tk] = nil } } @summaries = Hash.new { |sh, sk| sh[sk] = Hash.new { |th, tk| th[tk] = nil } } end |
Instance Attribute Details
#counters ⇒ Object (readonly)
Returns the value of attribute counters.
12 13 14 |
# File 'lib/yabeda/test_adapter.rb', line 12 def counters @counters end |
#gauges ⇒ Object (readonly)
Returns the value of attribute gauges.
12 13 14 |
# File 'lib/yabeda/test_adapter.rb', line 12 def gauges @gauges end |
#histograms ⇒ Object (readonly)
Returns the value of attribute histograms.
12 13 14 |
# File 'lib/yabeda/test_adapter.rb', line 12 def histograms @histograms end |
#summaries ⇒ Object (readonly)
Returns the value of attribute summaries.
12 13 14 |
# File 'lib/yabeda/test_adapter.rb', line 12 def summaries @summaries end |
Instance Method Details
#perform_counter_increment!(counter, tags, increment) ⇒ Object
47 48 49 |
# File 'lib/yabeda/test_adapter.rb', line 47 def perform_counter_increment!(counter, , increment) @counters[counter][] += increment end |
#perform_gauge_set!(gauge, tags, value) ⇒ Object
51 52 53 |
# File 'lib/yabeda/test_adapter.rb', line 51 def perform_gauge_set!(gauge, , value) @gauges[gauge][] = value end |
#perform_histogram_measure!(histogram, tags, value) ⇒ Object
55 56 57 |
# File 'lib/yabeda/test_adapter.rb', line 55 def perform_histogram_measure!(histogram, , value) @histograms[histogram][] = value end |
#perform_summary_observe!(summary, tags, value) ⇒ Object
59 60 61 |
# File 'lib/yabeda/test_adapter.rb', line 59 def perform_summary_observe!(summary, , value) @summaries[summary][] = value end |
#register_counter!(metric) ⇒ Object
31 32 33 |
# File 'lib/yabeda/test_adapter.rb', line 31 def register_counter!(metric) @counters[metric] end |
#register_gauge!(metric) ⇒ Object
35 36 37 |
# File 'lib/yabeda/test_adapter.rb', line 35 def register_gauge!(metric) @gauges[metric] end |
#register_histogram!(metric) ⇒ Object
39 40 41 |
# File 'lib/yabeda/test_adapter.rb', line 39 def register_histogram!(metric) @histograms[metric] end |
#register_summary!(metric) ⇒ Object
43 44 45 |
# File 'lib/yabeda/test_adapter.rb', line 43 def register_summary!(metric) @summaries[metric] end |
#reset! ⇒ Object
Call this method after every test example to quickly get blank state for the next test example
25 26 27 28 29 |
# File 'lib/yabeda/test_adapter.rb', line 25 def reset! [@counters, @gauges, @histograms, @summaries].each do |collection| collection.each_value(&:clear) # Reset tag-values hash to be empty end end |