Module: ScoutApm::Instruments::ActiveRecordUpdateInstruments

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

Instance Method Summary collapse

Instance Method Details

#save(*args, &block) ⇒ Object



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/scout_apm/instruments/active_record.rb', line 411

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



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/scout_apm/instruments/active_record.rb', line 428

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