class Yabeda::Datadog::ResponseHandler

Handle response from dogapi

Public Class Methods

call(metric) { || ... } click to toggle source
# File lib/yabeda/datadog/response_handler.rb, line 8
def call(metric)
  Logging.instance.debug("sending #{metric.name} metric")
  response = yield
  Logging.instance.debug("response on #{metric.name}: #{handle(response)}")
  response
end

Private Class Methods

handle(response) click to toggle source
# File lib/yabeda/datadog/response_handler.rb, line 17
def handle(response)
  if response.is_a? Array
    return response if response.count < 2
    raise response[1]["errors"].join(", ") if response[1].key?("errors")

    return "status: #{response[0]}, payload: #{response[1]}"
  end
  response
end