Sha256: 025e6101f724806fb5dd4fbdbc2e5603d66920ac56cb7cfdec7aec4ad714fb1b

Contents?: true

Size: 1.31 KB

Versions: 23

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'new_relic/agent/instrumentation/middleware_proxy'

DependencyDetection.defer do
  named :rails_middleware

  depends_on do
    defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i >= 3
  end

  depends_on do
    !::NewRelic::Agent.config[:disable_middleware_instrumentation]
  end

  executes do
    ::NewRelic::Agent.logger.info("Installing Rails 3+ middleware instrumentation")
    module ActionDispatch
      class MiddlewareStack
        class Middleware
          def build_with_new_relic(app)
            # MiddlewareProxy.wrap guards against double-wrapping here.
            # We need to instrument the innermost app (usually a RouteSet),
            # which will never itself be the return value from #build, but will
            # instead be the initial value of the app argument.
            wrapped_app = ::NewRelic::Agent::Instrumentation::MiddlewareProxy.wrap(app)
            result = build_without_new_relic(wrapped_app)
            ::NewRelic::Agent::Instrumentation::MiddlewareProxy.wrap(result)
          end

          alias_method :build_without_new_relic, :build
          alias_method :build, :build_with_new_relic
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
newrelic_rpm-3.14.3.313 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.14.2.312 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.14.1.311 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.14.0.305 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.13.2.302 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.13.1.300 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.13.0.299 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.12.1.298 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.12.0.288 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.11.2.286 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.11.1.284 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.11.0.283 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.10.0.279 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.9.9.275 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.9.8.273 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.9.7.266 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.9.6.257 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.9.5.251 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.9.4.245 lib/new_relic/agent/instrumentation/rails_middleware.rb
newrelic_rpm-3.9.3.241 lib/new_relic/agent/instrumentation/rails_middleware.rb