module ScoutApm::Instruments::ActiveRecordRelationInstruments

Public Class Methods

included(instrumented_class) click to toggle source
# File lib/scout_apm/instruments/active_record.rb, line 437
def self.included(instrumented_class)
  ::ActiveRecord::Relation.class_eval do
    alias_method :update_all_without_scout_instruments, :update_all
    alias_method :update_all, :update_all_with_scout_instruments

    alias_method :delete_all_without_scout_instruments, :delete_all
    alias_method :delete_all, :delete_all_with_scout_instruments

    alias_method :destroy_all_without_scout_instruments, :destroy_all
    alias_method :destroy_all, :destroy_all_with_scout_instruments
  end
end

Public Instance Methods

delete_all_with_scout_instruments(*args, &block) click to toggle source
# File lib/scout_apm/instruments/active_record.rb, line 465
def delete_all_with_scout_instruments(*args, &block)
  model = self.name

  req = ScoutApm::RequestManager.lookup
  layer = ScoutApm::Layer.new("ActiveRecord", Utils::ActiveRecordMetricName.new("", "#{model} Delete"))
  req.start_layer(layer)
  req.ignore_children!
  begin
    delete_all_without_scout_instruments(*args, &block)
  ensure
    req.acknowledge_children!
    req.stop_layer
  end
end
destroy_all_with_scout_instruments(*args, &block) click to toggle source
# File lib/scout_apm/instruments/active_record.rb, line 480
def destroy_all_with_scout_instruments(*args, &block)
  model = self.name

  req = ScoutApm::RequestManager.lookup
  layer = ScoutApm::Layer.new("ActiveRecord", Utils::ActiveRecordMetricName.new("", "#{model} Delete"))
  req.start_layer(layer)
  req.ignore_children!
  begin
    destroy_all_without_scout_instruments(*args, &block)
  ensure
    req.acknowledge_children!
    req.stop_layer
  end
end
update_all_with_scout_instruments(*args, &block) click to toggle source
# File lib/scout_apm/instruments/active_record.rb, line 450
def update_all_with_scout_instruments(*args, &block)
  model = self.name

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