class Hallmonitor::Outputters::Datadog
An outputter for Dogstatsd
Constants
- EventData
Simple
EventData
struct
Public Class Methods
new(dogstatsd, tags: {})
click to toggle source
Builds a new DogstatsdOutputter. @param dogstatsd [Datadog::Statsd] Dogstatd client instance to use @param tags [Hash] Default tags to apply to all metrics sent to this outputter
Calls superclass method
Hallmonitor::Outputter::new
# File lib/hallmonitor/outputters/datadog.rb, line 16 def initialize(dogstatsd, tags: {}) super('dogstatsd') @tags = {}.merge(tags) @statsd = dogstatsd end
Public Instance Methods
process(event)
click to toggle source
Sends events to datadog 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
# File lib/hallmonitor/outputters/datadog.rb, line 27 def process(event) event_data = build_event_data(event) write(event_data) end
Private Instance Methods
build_count_data(event)
click to toggle source
# File lib/hallmonitor/outputters/datadog.rb, line 60 def build_count_data(event) build_data(event, event.count, :count) end
build_data(event, value, type)
click to toggle source
:reek: FeatureEnvy
# File lib/hallmonitor/outputters/datadog.rb, line 65 def build_data(event, value, type) event_name = event.name tags = process_tags(event.tags) if value.is_a?(Hash) value.map do |name, value| EventData.new("#{event_name}.#{name}", value, tags, type) end else [EventData.new(event_name, value, tags, type)] end end
build_event_data(event)
click to toggle source
# File lib/hallmonitor/outputters/datadog.rb, line 41 def build_event_data(event) case event when Hallmonitor::TimedEvent build_timed_data(event) when Hallmonitor::GaugeEvent build_gauge_data(event) else build_count_data(event) end end
build_gauge_data(event)
click to toggle source
# File lib/hallmonitor/outputters/datadog.rb, line 56 def build_gauge_data(event) build_data(event, event.value, :gauge) end
build_timed_data(event)
click to toggle source
# File lib/hallmonitor/outputters/datadog.rb, line 52 def build_timed_data(event) build_data(event, event.duration, :timing) end
write(event_data)
click to toggle source
:reek: FeatureEnvy
# File lib/hallmonitor/outputters/datadog.rb, line 35 def write(event_data) event_data.each do |data| @statsd.send(data.type, data.name, data.value, tags: data.tags) end end