Sha256: e4a3ccc5f00d658d2b79ea7dffb9dc79b968558f957e0912215af6636b265afd

Contents?: true

Size: 820 Bytes

Versions: 1

Compression:

Stored size: 820 Bytes

Contents

require 'ddtrace/contrib/patcher'
require 'ddtrace/contrib/active_record/patches/abstract_adapter'
require 'ddtrace/contrib/active_record/events'

module Datadog
  module Contrib
    module ActiveRecord
      # Patcher enables patching of 'active_record' module.
      module Patcher
        include Contrib::Patcher

        module_function

        def patched?
          done?(:active_record)
        end

        def patch
          do_once(:active_record) do
            begin
              ::ActiveRecord::ConnectionAdapters::AbstractAdapter.send(:include, Patches::AbstractAdapter)
              Events.subscribe!
            rescue StandardError => e
              Datadog::Tracer.log.error("Unable to apply Active Record integration: #{e}")
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddtrace-0.18.0 lib/ddtrace/contrib/active_record/patcher.rb