class Slimy::Reporters::DatadogReporter

Reporter for sending data to datadog

this requires a DogstatsD instance to operate

Public Class Methods

new(dogstatsd) click to toggle source
# File lib/slimy/reporters/datadog.rb, line 10
def initialize(dogstatsd)
  @dogstatsd = dogstatsd
end

Public Instance Methods

report(context) click to toggle source

report the given context to datadog

# File lib/slimy/reporters/datadog.rb, line 15
def report(context)
  return unless context.reportable?

  sli_status = (context.success? ? "success" : "failure")
  current_span = Datadog.tracer.active_span
  if current_span.nil?
    Rails.logger.debug("COULD NOT FIND SPAN")
  else
    set_tags_on_span(context, sli_status, current_span)
    @dogstatsd.increment("sli.#{context.type}.#{sli_status}",
                         tags: context.tags)
  end
end
set_tags_on_span(context, sli_status, current_span) click to toggle source
# File lib/slimy/reporters/datadog.rb, line 29
def set_tags_on_span(context, sli_status, current_span)
  current_span.set_tag("sli_status", sli_status)
  current_span.set_tag("sli_deadline", context.deadline)
  context.tags.each_pair do |key, value|
    current_span.set_tag(key, value)
  end
end