Class: FnordMetric::ZeroConfigGauge
- Inherits:
-
Object
- Object
- FnordMetric::ZeroConfigGauge
- Defined in:
- lib/fnordmetric/zero_config_gauge.rb
Defined Under Namespace
Classes: EmtpyGauge
Constant Summary collapse
- TYPES =
[:_incr, :_decr, :_avg, :_min, :_max, :_set]
- Handler =
proc do if data[:gauge] gauge_key = data[:gauge].to_sym else FnordMetric.error("missing key for zero config event: gauge") next end unless data[:value] FnordMetric.error("missing key for zero config event: value") next end gauge = if namespace.gauges.has_key?(gauge_key) namespace.gauges[gauge_key] else namespace.opt_gauge(gauge_key, :flush_interval => data[:flush_interval], :average => (type == :_avg), :zero_config => true) end case type when :_set set_value gauge, data[:value].to_i when :_incr incr_tick gauge, data[:value].to_i when :_decr FnordMetric.error("_decr is not yet implemented") when :_avg incr_avg gauge, data[:value].to_i when :_min, :_max FnordMetric.error("_min/_max is not yet implemented") end end
Instance Method Summary collapse
-
#initialize(key, namespace) ⇒ ZeroConfigGauge
constructor
A new instance of ZeroConfigGauge.
- #method_missing(*msg) ⇒ Object
- #name ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(key, namespace) ⇒ ZeroConfigGauge
Returns a new instance of ZeroConfigGauge.
115 116 117 118 |
# File 'lib/fnordmetric/zero_config_gauge.rb', line 115 def initialize(key, namespace) @key = key @namespace = namespace end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*msg) ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'lib/fnordmetric/zero_config_gauge.rb', line 128 def method_missing(*msg) gauge = @namespace.gauges[@key] if gauge gauge.send(*msg) else EmtpyGauge.send(*msg) end end |
Instance Method Details
#name ⇒ Object
120 121 122 |
# File 'lib/fnordmetric/zero_config_gauge.rb', line 120 def name @key end |
#title ⇒ Object
124 125 126 |
# File 'lib/fnordmetric/zero_config_gauge.rb', line 124 def title @key end |