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) ⇒ StatsdOutputter
constructor
Builds a new StatsdOutputter.
-
#process(event) ⇒ Object
Sends events to statsd instance.
Constructor Details
#initialize(prefix, host = "localhost", port = 8125) ⇒ StatsdOutputter
Builds a new StatsdOutputter.
16 17 18 19 20 |
# File 'lib/hallmonitor/outputters/statsd_outputter.rb', line 16 def initialize(prefix, host="localhost", port=8125) raise "In order to use StatsdOutputter, statsd gem must be installed" unless defined?(Statsd) super(prefix) @statsd = Statsd.new(host).tap{|sd| sd.namespace = name} end |
Instance Method Details
#process(event) ⇒ Object
Sends events to statsd instance
23 24 25 26 27 28 29 30 31 |
# File 'lib/hallmonitor/outputters/statsd_outputter.rb', line 23 def process(event) if(event.respond_to?(:duration)) @statsd.timing(event.name, event.duration) elsif(event.respond_to?(:value)) @statsd.gauge(event.name, event.value) else @statsd.count(event.name, event.count) end end |