def self.instrument_builder builder_class
::NewRelic::Agent.logger.info "Installing deferred #{builder_class} instrumentation"
builder_class.class_eval do
class << self
attr_accessor :_nr_deferred_detection_ran
end
self._nr_deferred_detection_ran = false
include ::NewRelic::Agent::Instrumentation::RackBuilder
alias_method :to_app_without_newrelic, :to_app
alias_method :to_app, :to_app_with_newrelic_deferred_dependency_detection
if ::NewRelic::Agent::Instrumentation::RackHelpers.middleware_instrumentation_enabled?
::NewRelic::Agent.logger.info "Installing #{builder_class} middleware instrumentation"
alias_method :run_without_newrelic, :run
alias_method :run, :run_with_newrelic
alias_method :use_without_newrelic, :use
alias_method :use, :use_with_newrelic
end
end
def self.instrument_url_map url_map_class
url_map_class.class_eval do
alias_method :initialize_without_newrelic, :initialize
def initialize(map = {})
traced_map = ::NewRelic::Agent::Instrumentation::RackURLMap.generate_traced_map(map)
initialize_without_newrelic(traced_map)
end
end
end
end