Module: ScoutApm::Instruments::ActionView::ActionViewTemplateRendererInstruments

Defined in:
lib/scout_apm/instruments/action_view.rb

Instance Method Summary collapse

Instance Method Details

#render_template(*args) ⇒ Object

Don’t forward kwargs here, since Rails 3, 4, 5, 6 don’t use them, and it causes annoyances in the instrumentation



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/scout_apm/instruments/action_view.rb', line 134

def render_template(*args)
  req = ScoutApm::RequestManager.lookup

  maybe_template = args[1]

  template_name = args[0].virtual_path rescue nil # Works on Rails 3.2 -> end of Rails 5 series
  template_name ||= maybe_template.virtual_path rescue nil # Works on Rails 6 -> 6.1.3
  template_name ||= "Unknown"
  layer_name = template_name + "/Rendering"

  layer = ScoutApm::Layer.new("View", layer_name)
  layer.subscopable!

  begin
    req.start_layer(layer)
    super(*args)
  ensure
    req.stop_layer
  end
end