Class: ScoutApm::Instruments::MiddlewareDetailed
- Inherits:
-
Object
- Object
- ScoutApm::Instruments::MiddlewareDetailed
- Defined in:
- lib/scout_apm/instruments/middleware_detailed.rb
Defined Under Namespace
Classes: MiddlewareWrapper
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize(context) ⇒ MiddlewareDetailed
constructor
A new instance of MiddlewareDetailed.
- #install ⇒ Object
- #installed? ⇒ Boolean
- #logger ⇒ Object
Constructor Details
#initialize(context) ⇒ MiddlewareDetailed
Returns a new instance of MiddlewareDetailed.
14 15 16 17 |
# File 'lib/scout_apm/instruments/middleware_detailed.rb', line 14 def initialize(context) @context = context @installed = false end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
12 13 14 |
# File 'lib/scout_apm/instruments/middleware_detailed.rb', line 12 def context @context end |
Instance Method Details
#install ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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? ⇒ Boolean
23 24 25 |
# File 'lib/scout_apm/instruments/middleware_detailed.rb', line 23 def installed? @installed end |
#logger ⇒ Object
19 20 21 |
# File 'lib/scout_apm/instruments/middleware_detailed.rb', line 19 def logger context.logger end |