Class: Ventable::Statsd::Tracker
- Inherits:
-
Object
- Object
- Ventable::Statsd::Tracker
- Includes:
- Singleton
- Defined in:
- lib/ventable/statsd/tracker.rb
Overview
Main interface class which delegates some methods to the instance of statsd in order to increment, or gauge/set various metrics.
Instance Attribute Summary collapse
-
#enabled ⇒ Bool
set to false to bypass delegation.
-
#event_to_metric_proc ⇒ Proc
writeonly
optional proc returning event configuration hash.
-
#statsd(operation, *args, **opts, &block) ⇒ Object
A wrapper around the actual
Statsd
, which checks whether the gem is enabled or disabled before callingStatsd
.
Instance Method Summary collapse
Instance Attribute Details
#enabled ⇒ Bool
set to false to bypass delegation
19 20 21 |
# File 'lib/ventable/statsd/tracker.rb', line 19 def enabled @enabled end |
#event_to_metric_proc=(value) ⇒ Proc (writeonly)
optional proc returning event configuration hash
19 20 21 |
# File 'lib/ventable/statsd/tracker.rb', line 19 def event_to_metric_proc=(value) @event_to_metric_proc = value end |
#statsd(operation, *args, **opts, &block) ⇒ Object
A wrapper around the actual Statsd
, which checks whether the gem is enabled or disabled before calling Statsd
.
19 20 21 |
# File 'lib/ventable/statsd/tracker.rb', line 19 def statsd @statsd end |
Instance Method Details
#disable! ⇒ Object
45 46 47 |
# File 'lib/ventable/statsd/tracker.rb', line 45 def disable! self.enabled = false end |
#enable! ⇒ Object
41 42 43 |
# File 'lib/ventable/statsd/tracker.rb', line 41 def enable! self.enabled = true end |
#handle_event(event) ⇒ Object
66 67 68 69 70 |
# File 'lib/ventable/statsd/tracker.rb', line 66 def handle_event(event) ec = event_config(event) = ec[:options] || {} statsd(ec[:method], *[ec[:name], ec[:value]], **) end |