diff --git a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb index d359c31ffd..a43038c675 100644 --- a/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb +++ b/instrumentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb @@ -18,9 +18,17 @@ class << base # Contains ActiveRecord::Querying to be patched module ClassMethods - def find_by_sql(sql, binds = [], preparable: nil, &block) - tracer.in_span("#{self}.find_by_sql") do - super + if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("7.2.0.alpha") + def find_by_sql(sql, binds = [], preparable: nil, allow_retry: false, &block) + tracer.in_span("#{self}.find_by_sql") do + super + end + end + else + def find_by_sql(sql, binds = [], preparable: nil, &block) + tracer.in_span("#{self}.find_by_sql") do + super + end end end diff --git a/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec b/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec index bb89086e1a..af54aa0ee1 100644 --- a/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec +++ b/instrumentation/active_record/opentelemetry-instrumentation-active_record.gemspec @@ -34,6 +34,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.1' spec.add_development_dependency 'opentelemetry-test-helpers', '~> 0.3' + spec.add_development_dependency 'rails', '>= 6.1' spec.add_development_dependency 'rake', '~> 13.0' spec.add_development_dependency 'rubocop', '~> 1.60.1' spec.add_development_dependency 'rubocop-performance', '~> 1.20'