Module: ScoutApm::Instruments::ActiveRecordUpdateInstruments

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

Instance Method Summary collapse

Instance Method Details

#save(*args, &block) ⇒ Object



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/scout_apm/instruments/active_record.rb', line 328

def save(*args, &block)
  model = self.class.name
  operation = self.persisted? ? "Update" : "Create"

  req = ScoutApm::RequestManager.lookup
  layer = ScoutApm::Layer.new("ActiveRecord", Utils::ActiveRecordMetricName.new("", "#{model} #{operation}"))
  layer.desc = SqlList.new
  req.start_layer(layer)
  req.ignore_children!
  begin
    super(*args, &block)
  ensure
    req.acknowledge_children!
    req.stop_layer
  end
end

#save!(*args, &block) ⇒ Object



345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/scout_apm/instruments/active_record.rb', line 345

def save!(*args, &block)
  model = self.class.name
  operation = self.persisted? ? "Update" : "Create"

  req = ScoutApm::RequestManager.lookup
  layer = ScoutApm::Layer.new("ActiveRecord", Utils::ActiveRecordMetricName.new("", "#{model} #{operation}"))
  req.start_layer(layer)
  req.ignore_children!
  begin
    super(*args, &block)
  ensure
    req.acknowledge_children!
    req.stop_layer
  end
end