Class: Hallmonitor::Outputters::StatsdOutputter
- Inherits:
-
Hallmonitor::Outputter
- Object
- Hallmonitor::Outputter
- Hallmonitor::Outputters::StatsdOutputter
- Defined in:
- lib/hallmonitor/outputters/statsd_outputter.rb
Overview
An outputter for StatsD
Instance Attribute Summary
Attributes inherited from Hallmonitor::Outputter
Instance Method Summary collapse
-
#initialize(prefix, host = 'localhost', port = 8125, transformer = nil) ⇒ StatsdOutputter
constructor
Builds a new StatsdOutputter.
-
#process(event) ⇒ Object
Sends events to statsd instance If the event’s value field is a hash, this will send multiple events to statsd with the original name suffixed by the name of the events in the hash.
Constructor Details
#initialize(prefix, host = 'localhost', port = 8125, transformer = nil) ⇒ StatsdOutputter
Builds a new StatsdOutputter.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hallmonitor/outputters/statsd_outputter.rb', line 20 def initialize(prefix, host = 'localhost', port = 8125, transformer = nil) unless defined?(Statsd) fail 'In order to use StatsdOutputter, statsd gem must be installed' end if transformer && !transformer.respond_to?(:transform) fail 'Supplied transformer does not respond to :transform' end super(prefix) @statsd = Statsd.new(host).tap { |sd| sd.namespace = name } @transformer = transformer end |
Instance Method Details
#process(event) ⇒ Object
Sends events to statsd instance If the event’s value field is a hash, this will send multiple events to statsd with the original name suffixed by the name of the events in the hash
38 39 40 41 42 43 44 45 46 |
# File 'lib/hallmonitor/outputters/statsd_outputter.rb', line 38 def process(event) if event.is_a?(Hallmonitor::TimedEvent) process_timed_event(event) elsif event.is_a?(Hallmonitor::GaugeEvent) process_gauge_event(event) else process_event(event) end end |