Class: ScoutApm::Instruments::MiddlewareSummary

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

Defined Under Namespace

Classes: MiddlewareSummaryWrapper

Instance Method Summary collapse

Instance Method Details

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



9
10
11
12
# File 'lib/scout_apm/instruments/middleware_summary.rb', line 9

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

#installObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/scout_apm/instruments/middleware_summary.rb', line 18

def install
  @installed = true

  if defined?(ActionDispatch) && defined?(ActionDispatch::MiddlewareStack)
    ScoutApm::Agent.instance.logger.info("Instrumenting Middleware")
    ActionDispatch::MiddlewareStack.class_eval do
      def build_with_scout_instruments(app = nil, &block)
        mw_stack = build_without_scout_instruments(app) { block.call if block }
        MiddlewareSummaryWrapper.new(mw_stack)
      end

      alias_method :build_without_scout_instruments, :build
      alias_method :build, :build_with_scout_instruments
    end
  end
end

#installed?Boolean

Returns:

  • (Boolean)


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

def installed?
  @installed
end