Module: ClassLoadingWatcher

Extended by:
ClassLoadingWatcher
Included in:
ClassLoadingWatcher
Defined in:
lib/new_relic/agent/patch_const_missing.rb

Overview

This class is for debugging purposes only. It inserts instrumentation into class loading to verify that no classes are being loaded on the new relic thread, which can cause problems in the class loader code. It is only loaded by agent.rb when a particular newrelic.yml option is set.

Defined Under Namespace

Modules: SanityCheck

Constant Summary collapse

@@background_thread =
nil
@@flag_const_missing =
nil

Instance Method Summary collapse

Instance Method Details

#background_threadObject



14
15
16
# File 'lib/new_relic/agent/patch_const_missing.rb', line 14

def background_thread
  @@background_thread
end

#background_thread=(thread) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/new_relic/agent/patch_const_missing.rb', line 24

def background_thread=(thread)
  @@background_thread = thread
  
  # these tests verify that check is working
=begin
      @@background_thread = nil
      bad = ConstMissingInForegroundThread rescue nil
      @@background_thread = thread
      bad = ConstMissingInBackgroundThread rescue nil
      require 'new_relic/agent/patch_const_missing'
      load 'new_relic/agent/patch_const_missing.rb'
=end
end

#disable_warningObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/new_relic/agent/patch_const_missing.rb', line 81

def disable_warning
  Object.class_eval do
    if defined?(non_new_relic_require)
      alias_method :require, :non_new_relic_require
      undef non_new_relic_require
    end
    
    if defined?(non_new_relic_load)
      alias_method :load, :non_new_relic_load
      undef non_new_relic_load
    end
  end
  Module.class_eval do
    if defined?(non_new_relic_const_missing)
      alias_method :const_missing, :non_new_relic_const_missing
      undef non_new_relic_const_missing
    end
  end
end

#enable_warningObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/new_relic/agent/patch_const_missing.rb', line 61

def enable_warning
  Object.class_eval do
    if !defined?(non_new_relic_require)
      alias_method :non_new_relic_require, :require
      alias_method :require, :new_relic_require
    end
    
    if !defined?(non_new_relic_load)
      alias_method :non_new_relic_load, :load
      alias_method :load, :new_relic_load
    end
  end
  Module.class_eval do
    if !defined?(non_new_relic_const_missing)
      alias_method :non_new_relic_const_missing, :const_missing
      alias_method :const_missing, :new_relic_const_missing
    end
  end
end

#flag_const_missingObject



17
18
19
# File 'lib/new_relic/agent/patch_const_missing.rb', line 17

def flag_const_missing
  @@flag_const_missing
end

#flag_const_missing=(val) ⇒ Object



20
21
22
# File 'lib/new_relic/agent/patch_const_missing.rb', line 20

def flag_const_missing=(val)
  @@flag_const_missing = val
end