Module: NewRelic::SupportabilityHelper

Included in:
Agent, Agent::DistributedTracing
Defined in:
lib/new_relic/supportability_helper.rb

Constant Summary collapse

API_SUPPORTABILITY_PREFIX =
'Supportability/API/'.freeze
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

[
  :insert_distributed_trace_headers,
  :accept_distributed_trace_headers,
  :add_custom_attributes,
  :add_custom_log_attributes,
  :add_custom_span_attributes,
  :add_instrumentation,
  :add_method_tracer,
  :add_transaction_tracer,
  :after_fork,
  :browser_timing_header,
  :disable_all_tracing,
  :disable_sql_recording,
  :drop_buffered_data,
  :get_request_metadata,
  :get_response_metadata,
  :get_transaction_name,
  :ignore_apdex,
  :ignore_enduser,
  :ignore_error_filter,
  :ignore_transaction,
  :increment_metric,
  :manual_start,
  :newrelic_ignore,
  :newrelic_ignore_apdex,
  :newrelic_ignore_enduser,
  :notice_error,
  :notice_sql,
  :notice_statement,
  :perform_action_with_newrelic_trace,
  :process_request_metadata,
  :process_response_metadata,
  :record_custom_event,
  :record_metric,
  :record_llm_feedback_event,
  :recording_web_transaction?,
  :require_test_helper,
  :set_error_group_callback,
  :set_llm_token_count_callback,
  :set_segment_callback,
  :set_sql_obfuscator,
  :set_transaction_name,
  :set_user_id,
  :shutdown,
  :start_segment,
  :trace,
  :traced_thread,
  :trace_execution_scoped,
  :trace_execution_unscoped,
  :wrap
].reduce({}) do |h, o|
  h[o] = API_SUPPORTABILITY_PREFIX + o.to_s
  h
end

Instance Method Summary collapse

Instance Method Details

#record_api_supportability_metric(method_name) ⇒ Object



67
68
69
70
71
72
73
74
# 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) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
79
80
81
82
83
84
85
86
# 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