class ScoutApm::Instruments::MiddlewareDetailed

Attributes

context[R]

Public Class Methods

new(context) click to toggle source
# File lib/scout_apm/instruments/middleware_detailed.rb, line 14
def initialize(context)
  @context = context
  @installed = false
end

Public Instance Methods

build(app) click to toggle source
# File lib/scout_apm/instruments/middleware_detailed.rb, line 32
def build(app)
  ScoutApm::Agent.instance.context.logger.info("Instrumenting Middleware #{klass.name}")
  new_mw = klass.new(app, *args, &block)
  MiddlewareWrapper.new(new_mw, klass.name)
end
install() click to toggle source
# File lib/scout_apm/instruments/middleware_detailed.rb, line 27
def install
  if defined?(ActionDispatch) && defined?(ActionDispatch::MiddlewareStack) && defined?(ActionDispatch::MiddlewareStack::Middleware)
    @installed = true

    ActionDispatch::MiddlewareStack::Middleware.class_eval do
      def build(app)
        ScoutApm::Agent.instance.context.logger.info("Instrumenting Middleware #{klass.name}")
        new_mw = klass.new(app, *args, &block)
        MiddlewareWrapper.new(new_mw, klass.name)
      end
    end
  end
end
installed?() click to toggle source
# File lib/scout_apm/instruments/middleware_detailed.rb, line 23
def installed?
  @installed
end
logger() click to toggle source
# File lib/scout_apm/instruments/middleware_detailed.rb, line 19
def logger
  context.logger
end