Class: ScoutApm::Instruments::MiddlewareDetailed

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/instruments/middleware_detailed.rb

Defined Under Namespace

Classes: MiddlewareWrapper

Instance Method Summary collapse

Instance Method Details

#initalize(logger = ScoutApm::Agent.instance.logger) ⇒ Object



14
15
16
17
# File 'lib/scout_apm/instruments/middleware_detailed.rb', line 14

def initalize(logger=ScoutApm::Agent.instance.logger)
  @logger = logger
  @installed = false
end

#installObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/scout_apm/instruments/middleware_detailed.rb', line 23

def install
  @installed = true

  if defined?(ActionDispatch) && defined?(ActionDispatch::MiddlewareStack) && defined?(ActionDispatch::MiddlewareStack::Middleware)
    ActionDispatch::MiddlewareStack::Middleware.class_eval do
      def build(app)
        ScoutApm::Agent.instance.logger.info("Building Middleware #{klass.name}")
        new_mw = klass.new(app, *args, &block)
        MiddlewareWrapper.new(new_mw, klass.name)
      end
    end
  end
end

#installed?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/scout_apm/instruments/middleware_detailed.rb', line 19

def installed?
  @installed
end