Class: ScoutApm::Instruments::ActionView
- Inherits:
-
Object
- Object
- ScoutApm::Instruments::ActionView
- Defined in:
- lib/scout_apm/instruments/action_view.rb
Overview
instrumentation for Rails 3 and Rails 4 is the same.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize(context) ⇒ ActionView
constructor
A new instance of ActionView.
- #install ⇒ Object
- #installed? ⇒ Boolean
- #logger ⇒ Object
Constructor Details
#initialize(context) ⇒ ActionView
Returns a new instance of ActionView.
7 8 9 10 |
# File 'lib/scout_apm/instruments/action_view.rb', line 7 def initialize(context) @context = context @installed = false end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/scout_apm/instruments/action_view.rb', line 5 def context @context end |
Instance Method Details
#install ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/scout_apm/instruments/action_view.rb', line 20 def install if defined?(::ActionView) && defined?(::ActionView::PartialRenderer) @installed = true logger.info "Instrumenting ActionView::PartialRenderer" ::ActionView::PartialRenderer.class_eval do include ScoutApm::Tracer instrument_method :render_partial, :type => "View", :name => '#{@template.virtual_path rescue "Unknown Partial"}/Rendering', :scope => true instrument_method :collection_with_template, :type => "View", :name => '#{@template.virtual_path rescue "Unknown Collection"}/Rendering', :scope => true end logger.info "Instrumenting ActionView::TemplateRenderer" ::ActionView::TemplateRenderer.class_eval do include ScoutApm::Tracer instrument_method :render_template, :type => "View", :name => '#{args[0].virtual_path rescue "Unknown"}/Rendering', :scope => true end end end |
#installed? ⇒ Boolean
16 17 18 |
# File 'lib/scout_apm/instruments/action_view.rb', line 16 def installed? @installed end |
#logger ⇒ Object
12 13 14 |
# File 'lib/scout_apm/instruments/action_view.rb', line 12 def logger context.logger end |