24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/datadog/appsec/contrib/active_record/patcher.rb', line 24
def patch
ActiveSupport.on_load :active_record do
instrumentation_module = if ::ActiveRecord.gem_version >= Gem::Version.new('7.1')
Instrumentation::InternalExecQueryAdapterPatch
else
Instrumentation::ExecQueryAdapterPatch
end
if defined?(::ActiveRecord::ConnectionAdapters::SQLite3Adapter)
::ActiveRecord::ConnectionAdapters::SQLite3Adapter.prepend(instrumentation_module)
end
if defined?(::ActiveRecord::ConnectionAdapters::Mysql2Adapter)
::ActiveRecord::ConnectionAdapters::Mysql2Adapter.prepend(instrumentation_module)
end
if defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
unless defined?(::ActiveRecord::ConnectionAdapters::JdbcAdapter)
instrumentation_module = Instrumentation::ExecuteAndClearAdapterPatch
end
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(instrumentation_module)
end
end
end
|