module ScoutApm::Instruments::ActiveRecordFinderMethodsInstruments

Public Class Methods

included(instrumented_class) click to toggle source
# File lib/scout_apm/instruments/active_record.rb, line 333
def self.included(instrumented_class)
  ScoutApm::Agent.instance.context.logger.info "Instrumenting ActiveRecord::FinderMethods - #{instrumented_class.inspect}"
  instrumented_class.class_eval do
    unless instrumented_class.method_defined?(:find_with_associations_without_scout_instruments)
      alias_method :find_with_associations_without_scout_instruments, :find_with_associations
      alias_method :find_with_associations, :find_with_associations_with_scout_instruments
    end
  end
end

Public Instance Methods

find_with_associations_with_scout_instruments(*args, &block) click to toggle source
# File lib/scout_apm/instruments/active_record.rb, line 343
def find_with_associations_with_scout_instruments(*args, &block)
  req = ScoutApm::RequestManager.lookup
  layer = ScoutApm::Layer.new("ActiveRecord", Utils::ActiveRecordMetricName::DEFAULT_METRIC)
  layer.annotate_layer(:ignorable => true)
  layer.desc = SqlList.new
  req.start_layer(layer)
  req.ignore_children!
  begin
    find_with_associations_without_scout_instruments(*args, &block)
  ensure
    req.acknowledge_children!
    req.stop_layer
  end
end