Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bill Kayser
committed
Jan 12, 2009
1 parent
773227e
commit 639c65e
Showing
3 changed files
with
39 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
# This class is for debugging purposes only. | ||
# | ||
class Class | ||
class Module | ||
@@newrelic_agent_thread = nil | ||
def new_relic_const_missing(*args) | ||
if Thread.current == @agent_thread | ||
STDERR.puts "Agent background thread shouldn't be calling const_missing!!!" | ||
STDERR.puts caller.join("\n") | ||
exit -1 | ||
if Thread.current == @@newrelic_agent_thread | ||
msg = "Agent background thread shouldn't be calling const_missing (#{args.inspect}) \n" | ||
msg << caller[0..4].join(" \n") | ||
NewRelic::Config.instance.log.warn msg | ||
end | ||
|
||
original_const_missing(*args) | ||
end | ||
|
||
alias_method :original_const_missing, :const_missing | ||
alias_method :const_missing, :new_relic_const_missing | ||
def newrelic_enable_warning | ||
Module.class_eval do | ||
if !defined?(original_const_missing) | ||
alias_method :original_const_missing, :const_missing | ||
alias_method :const_missing, :new_relic_const_missing | ||
end | ||
end | ||
end | ||
def newrelic_disable_warning | ||
Module.class_eval do | ||
alias_method :const_missing, :original_const_missing if defined?(original_const_missing) | ||
end | ||
end | ||
|
||
def new_relic_set_agent_thread(thread) | ||
@agent_thread = thread | ||
def newrelic_set_agent_thread(thread) | ||
@@newrelic_agent_thread = thread | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters