Module: ScoutApm::Instruments::ActionView::ActionViewPartialRendererInstruments

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

Instance Method Summary collapse

Instance Method Details

#collection_with_template(*args, **kwargs) ⇒ Object

This method was moved in Rails 6.1 to CollectionRender.



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/scout_apm/instruments/action_view.rb', line 164

def collection_with_template(*args, **kwargs)
  req = ScoutApm::RequestManager.lookup

  maybe_template = args[1]

  template_name = @template.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.0.6
  template_name ||= "Unknown Collection"
  layer_name = template_name + "/Rendering"

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

  begin
    req.start_layer(layer)
    if ScoutApm::Agent.instance.context.environment.supports_kwarg_delegation?
      super(*args, **kwargs)
    else
      super(*args)
    end
  ensure
    req.stop_layer
  end
end

#render_partial(*args, **kwargs) ⇒ Object

In Rails 6, the signature changed to pass the view & template args directly, as opposed to through the instance var New signature is: def render_partial(view, template)



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/scout_apm/instruments/action_view.rb', line 138

def render_partial(*args, **kwargs)
  req = ScoutApm::RequestManager.lookup

  maybe_template = args[1]

  template_name = @template.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.0.6
  template_name ||= "Unknown Partial"

  layer_name = template_name + "/Rendering"
  layer = ScoutApm::Layer.new("View", layer_name)
  layer.subscopable!

  begin
    req.start_layer(layer)
    if ScoutApm::Agent.instance.context.environment.supports_kwarg_delegation?
      super(*args, **kwargs)
    else
      super(*args)
    end
  ensure
    req.stop_layer
  end
end

#render_partial_template(*args, **kwargs) ⇒ Object

In Rails 6.1, render_partial was renamed to render_partial_template



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/scout_apm/instruments/action_view.rb', line 111

def render_partial_template(*args, **kwargs)
  req = ScoutApm::RequestManager.lookup

  # Template was moved to the third argument in Rails 6.1.
  maybe_template = args[2]

  template_name ||= maybe_template.virtual_path rescue nil
  template_name ||= "Unknown Partial"

  layer_name = template_name + "/Rendering"
  layer = ScoutApm::Layer.new("View", layer_name)
  layer.subscopable!

  begin
    req.start_layer(layer)
    if ScoutApm::Agent.instance.context.environment.supports_kwarg_delegation?
      super(*args, **kwargs)
    else
      super(*args)
    end
  ensure
    req.stop_layer
  end
end