Sha256: ab724ef9a389a5bf10fec36b3514b414cbae14c400c2fc4880dcd6be59dd74b6

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'new_relic/agent/instrumentation/active_record_subscriber'
require 'new_relic/agent/instrumentation/active_record_prepend'

DependencyDetection.defer do
  named :active_record_5

  depends_on do
    defined?(::ActiveRecord) && defined?(::ActiveRecord::Base) &&
      defined?(::ActiveRecord::VERSION) &&
      ::ActiveRecord::VERSION::MAJOR.to_i == 5
  end

  depends_on do
    !NewRelic::Agent.config[:disable_activerecord_instrumentation] &&
      !NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.subscribed?
  end

  executes do
    ::NewRelic::Agent.logger.info 'Installing ActiveRecord 5 instrumentation'
  end

  executes do
    ActiveSupport::Notifications.subscribe('sql.active_record',
      NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.new)

    ActiveSupport.on_load(:active_record) do
      ::NewRelic::Agent::PrependSupportability.record_metrics_for(::ActiveRecord::Base, ::ActiveRecord::Relation)
      ::ActiveRecord::Base.prepend ::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions
      ::ActiveRecord::Relation.prepend ::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::RelationExtensions

      if ::ActiveRecord::VERSION::MINOR.to_i == 1 &&
         ::ActiveRecord::VERSION::TINY.to_i >= 6
        ::ActiveRecord::Base.prepend ::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions516
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
newrelic_rpm-6.2.0.354 lib/new_relic/agent/instrumentation/active_record_5.rb
newrelic_rpm-6.1.0.352 lib/new_relic/agent/instrumentation/active_record_5.rb
newrelic_rpm-6.0.0.351 lib/new_relic/agent/instrumentation/active_record_5.rb
newrelic_rpm-5.7.0.350 lib/new_relic/agent/instrumentation/active_record_5.rb
newrelic_rpm-5.6.0.349 lib/new_relic/agent/instrumentation/active_record_5.rb
newrelic_rpm-5.5.0.348 lib/new_relic/agent/instrumentation/active_record_5.rb
newrelic_rpm-5.4.0.347 lib/new_relic/agent/instrumentation/active_record_5.rb
newrelic_rpm-5.3.0.346 lib/new_relic/agent/instrumentation/active_record_5.rb
newrelic_rpm-5.2.0.345 lib/new_relic/agent/instrumentation/active_record_5.rb
newrelic_rpm-5.1.0.344 lib/new_relic/agent/instrumentation/active_record_5.rb