Method: NewRelic::Agent::StatsHash#handle_stats_lookup_error

Defined in:
lib/new_relic/agent/stats_engine/stats_hash.rb

#handle_stats_lookup_error(key, hash, error) ⇒ Object

[View source]

121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 121

def handle_stats_lookup_error(key, hash, error)
  # This only happen in the case of a corrupted default_proc
  # Side-step it manually, notice the issue, and carry on....
  NewRelic::Agent.instance.error_collector \
    .notice_agent_error(StatsHashLookupError.new(error, hash, key))
  stats = NewRelic::Agent::Stats.new
  hash[key] = stats
  # Try to restore the default_proc so we won't continually trip the error
  if hash.respond_to?(:default_proc=)
    hash.default_proc = proc { |h, k| h[k] = NewRelic::Agent::Stats.new }
  end
  stats
end