Module: ClassLoadingWatcher::SanityCheck

Included in:
Module, Object
Defined in:
lib/new_relic/agent/patch_const_missing.rb

Overview

require ‘new_relic/agent/patch_const_missing’

load 'new_relic/agent/patch_const_missing.rb'

Instance Method Summary collapse

Instance Method Details

#new_relic_check_for_badness(*args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/new_relic/agent/patch_const_missing.rb', line 28

def new_relic_check_for_badness(*args)
  
  if Thread.current == ClassLoadingWatcher.background_thread    
    msg = "Agent background thread shouldn't be loading classes (#{args.inspect})\n"
    
    exception = NewRelic::Agent::BackgroundLoadingError.new(msg.clone)
    exception.set_backtrace(caller)
    
    NewRelic::Agent.instance.error_collector.notice_error(nil, nil, [], exception)
    msg << caller.join("\n")
    
    NewRelic::Config.instance.log.error msg
  end
end