module NewRelic::SupportabilityHelper

Constants

API_SUPPORTABILITY_METRICS

pre-instantiate these strings as they may be used multiple times per transaction, just to eke out a bit less performance hit

API_SUPPORTABILITY_PREFIX

Public Instance Methods

record_api_supportability_metric(method_name) click to toggle source
# File lib/new_relic/supportability_helper.rb, line 67
def record_api_supportability_metric(method_name)
  agent = NewRelic::Agent.agent or return
  if metric = API_SUPPORTABILITY_METRICS[method_name]
    agent.stats_engine.tl_record_unscoped_metrics(metric, &:increment_count)
  else
    NewRelic::Agent.logger.debug("API supportability metric not found for :#{method_name}")
  end
end
valid_api_argument_class?(arg, name, klass) click to toggle source
# File lib/new_relic/supportability_helper.rb, line 76
def valid_api_argument_class?(arg, name, klass)
  return true if arg.is_a?(klass)

  caller_location = caller_locations(1..1).first.label

  message = "Bad argument passed to ##{caller_location}. " \
    "Expected #{klass} for `#{name}` but got #{arg.class}"

  NewRelic::Agent.logger.warn(message)
  false
end