Method: NewRelic::Agent::ErrorTraceAggregator#notice_agent_error

Defined in:
lib/new_relic/agent/error_trace_aggregator.rb

#notice_agent_error(exception) ⇒ Object

*Use sparingly for difficult to track bugs.*

Track internal agent errors for communication back to New Relic. To use, make a specific subclass of NewRelic::Agent::InternalAgentError, then pass an instance of it to this method when your problem occurs.

Limits are treated differently for these errors. We only gather one per class per harvest, disregarding (and not impacting) the app error queue limit.

[View source]

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/new_relic/agent/error_trace_aggregator.rb', line 74

def notice_agent_error(exception)
  return unless exception.class < NewRelic::Agent::InternalAgentError

  # Log 'em all!
  NewRelic::Agent.logger.info(exception)

  @lock.synchronize do
    # Already seen this class once? Bail!
    return if @errors.any? { |err| err.exception_class_name == exception.class.name }

    noticed_error = NewRelic::Agent.instance.error_collector.create_noticed_error(exception,
      {metric: 'NewRelic/AgentError'})
    noticed_error.stack_trace = caller.dup unless exception.backtrace

    @errors << noticed_error
  end
rescue => e
  NewRelic::Agent.logger.info('Unable to capture internal agent error due to an exception:', e)
end