Class: Hallmonitor::Outputters::DogstatsdOutputter
- Inherits:
-
Hallmonitor::Outputter
- Object
- Hallmonitor::Outputter
- Hallmonitor::Outputters::DogstatsdOutputter
- Defined in:
- lib/hallmonitor/outputters/dogstatsd_outputter.rb
Overview
An outputter for Dogstatsd
Instance Attribute Summary
Attributes inherited from Hallmonitor::Outputter
Instance Method Summary collapse
-
#initialize(prefix, host = '127.0.0.1', port = 8125, tags: {}) ⇒ DogstatsdOutputter
constructor
Builds a new DogstatsdOutputter.
- #process(event) ⇒ Object
-
#process_tags(tags) ⇒ 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 = '127.0.0.1', port = 8125, tags: {}) ⇒ DogstatsdOutputter
Builds a new DogstatsdOutputter.
16 17 18 19 20 21 22 23 24 |
# File 'lib/hallmonitor/outputters/dogstatsd_outputter.rb', line 16 def initialize(prefix, host = '127.0.0.1', port = 8125, tags: {}) unless defined?(Datadog::Statsd) fail 'In order to use DogstatsdOutputter, dogstatsd-ruby gem must be installed' end super(prefix) @tags = {}.merge() @statsd = Datadog::Statsd.new(host).tap { |sd| sd.namespace = name } end |
Instance Method Details
#process(event) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/hallmonitor/outputters/dogstatsd_outputter.rb', line 35 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 |
#process_tags(tags) ⇒ 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
31 32 33 |
# File 'lib/hallmonitor/outputters/dogstatsd_outputter.rb', line 31 def () @tags.merge().map {|key, value| "#{key}:#{value}"} end |