Module: ScoutApm::Instruments::ActiveRecordUpdateInstruments

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

Instance Method Summary collapse

Instance Method Details

#save(*args, &block) ⇒ Object



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/scout_apm/instruments/active_record.rb', line 352

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



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/scout_apm/instruments/active_record.rb', line 369

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