Sha256: fa2fcc1e46a0ae46837dec3eadeacbd0cb0c380a4db32086a9580439ff537f98

Contents?: true

Size: 1.67 KB

Versions: 39

Compression:

Stored size: 1.67 KB

Contents

module OneApm
  module Agent
    module Instrumentation
      module RackBuilder

        def run_with_oneapm(app, *args)
          unless OneApm::Manager.config[:disable_rack_middleware]
            wrapped_app = ::OneApm::Rack::MiddlewareWrapper.wrap(app, true)
            run_without_oneapm(wrapped_app, *args)
          else
            run_without_oneapm(app, *args)
          end
        end

        def use_with_oneapm(middleware_class, *args, &blk)
          unless OneApm::Manager.config[:disable_rack_middleware]
            wrapped_middleware_class = ::OneApm::Rack::MiddlewareWrapper.wrap_class(middleware_class)
            use_without_oneapm(wrapped_middleware_class, *args, &blk)
          else
            use_without_oneapm(middleware_class, *args, &blk)
          end
        end

        # defered detection to avoid something later required
        def to_app_with_oneapm_deferred_library_detection
          unless ::Rack::Builder._oa_deferred_detection_ran
            OneApm::Manager.logger.info "Doing deferred library-detection before Rack startup"
            LibraryDetection.detect!
            ::Rack::Builder._oa_deferred_detection_ran = true
          end

          result = to_app_without_oneapm
          _check_for_late_instrumentation(result)

          result
        end

        def _check_for_late_instrumentation(app)
          return if @checked_for_late_instrumentation
          @checked_for_late_instrumentation = true
          unless OneApm::Manager.config[:disable_rack_middleware]
            if ::OneApm::Rack::MiddlewareWrapper.needs_wrapping?(app)
              # TODO Fix it in the future
            end
          end
        end

      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
oneapm_rpm-1.2.9.rc1 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.8 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.8.rc1 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.7 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.7.rc1 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.6 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.6.rc1 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.5 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.5.rc1 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.4 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.4.rc1 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.3 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.3.rc2 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.2 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.2.rc lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.1 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.1.rc lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.2.0 lib/one_apm/inst/rack/rack_builder.rb
oneapm_rpm-1.1.3 lib/one_apm/inst/rack/rack_builder.rb