Class: Hallmonitor::Outputters::StatsdOutputter
- Inherits:
-
Hallmonitor::Outputter
- Object
- Hallmonitor::Outputter
- Hallmonitor::Outputters::StatsdOutputter
- Defined in:
- lib/hallmonitor/outputters/statsd_outputter.rb
Instance Attribute Summary
Attributes inherited from Hallmonitor::Outputter
Instance Method Summary collapse
-
#initialize(prefix, host = "localhost", port = 8125) ⇒ StatsdOutputter
constructor
A new instance of StatsdOutputter.
- #process(event) ⇒ Object
Methods inherited from Hallmonitor::Outputter
add_outputter, output, outputters
Constructor Details
#initialize(prefix, host = "localhost", port = 8125) ⇒ StatsdOutputter
Returns a new instance of StatsdOutputter.
9 10 11 12 13 |
# File 'lib/hallmonitor/outputters/statsd_outputter.rb', line 9 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
15 16 17 18 19 20 21 22 23 |
# File 'lib/hallmonitor/outputters/statsd_outputter.rb', line 15 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 |