Skip to content

Commit

Permalink
Allow external definitions of control and framework definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Kayser committed Mar 5, 2010
1 parent 8d5cf3a commit 05801ae
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/new_relic/local_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class LocalEnvironment
alias environment dispatcher

def initialize
# Extend self with any any submodules of LocalEnvironment. These can override
# the discover methods to discover new framworks and dispatchers.
NewRelic::LocalEnvironment.constants.each do | const |
mod = NewRelic::LocalEnvironment.const_get const
self.extend mod if mod.instance_of? Module
end

discover_framework
discover_dispatcher
@dispatcher = nil if @dispatcher == :none
Expand Down Expand Up @@ -155,7 +162,7 @@ def delayed_worker=(worker)
# Although you can override the framework with NEWRELIC_DISPATCHER this
# is not advisable since it implies certain api's being available.
def discover_dispatcher
@dispatcher = ENV['NEWRELIC_DISPATCHER'] && ENV['NEWRELIC_DISPATCHER'].to_sym
@dispatcher ||= ENV['NEWRELIC_DISPATCHER'] && ENV['NEWRELIC_DISPATCHER'].to_sym
dispatchers = %w[passenger torquebox glassfish thin mongrel litespeed webrick fastcgi unicorn sinatra]
while dispatchers.any? && @dispatcher.nil?
send 'check_for_'+(dispatchers.shift)
Expand All @@ -168,7 +175,7 @@ def discover_framework
#
# Note that the odd defined? sequence is necessary to work around a bug in an older version
# of JRuby.
@framework = case
@framework ||= case
when ENV['NEWRELIC_FRAMEWORK'] then ENV['NEWRELIC_FRAMEWORK'].to_sym
when defined?(::NewRelic::TEST) then :test
when defined?(::Merb) && defined?(::Merb::Plugins) then :merb
Expand Down

0 comments on commit 05801ae

Please sign in to comment.