Sha256: 4d45d446bca0c1b3ed3ce81b397a420ebd5be6392e83a0af40b8f2fdf7516faf

Contents?: true

Size: 1.16 KB

Versions: 17

Compression:

Stored size: 1.16 KB

Contents

# encoding: utf-8


require 'ting_yun/instrumentation/middleware_proxy'

TingYun::Support::LibraryDetection.defer do
  named :rails_middleware

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

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

  executes do
    ::TingYun::Agent.logger.info("Installing Rails 3+ middleware instrumentation")
    module ActionDispatch
      class MiddlewareStack
        class Middleware
          def build_with_ting_yun(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 = ::TingYun::Instrumentation::MiddlewareProxy.wrap(app)
            result = build_without_ting_yun(wrapped_app)
            ::TingYun::Instrumentation::MiddlewareProxy.wrap(result)
          end

          alias_method :build_without_ting_yun, :build
          alias_method :build, :build_with_ting_yun
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
tingyun_rpm-3.2.0 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.6.1 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.5.0 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.4.2 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.4.1 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.3.1 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.3.0 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.2.0 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.1.4.2 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.1.4.1 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.1.4 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.1.3 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.1.2 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.1.1 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.1.0 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.0.7 lib/ting_yun/instrumentation/rails_middleware.rb
tingyun_rpm-1.0.6 lib/ting_yun/instrumentation/rails_middleware.rb