Skip to content

Commit

Permalink
fix: instrumentation/active_record: add :allow_retry option to find_b…
Browse files Browse the repository at this point in the history
…y_sql patch

Rails 7.2 (rails/rails@eabcff2) introduces the :allow_retry option for this method, so we need to add it to this patch to maintain compatibility.
  • Loading branch information
andrewn617 committed Mar 26, 2024
1 parent d206c11 commit 4d79b29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 4d79b29

Please sign in to comment.