-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: instrumentation/active_record: add :allow_retry
option to find_by_sql
patch
#915
fix: instrumentation/active_record: add :allow_retry
option to find_by_sql
patch
#915
Conversation
0a3ac84
to
4d79b29
Compare
Do we need the condition? |
I think we do. We must honor the monkey patched class method signatures. Without that condition, the side effect will be changing the public API to add an option that does not exist. Though it will be backward compatible it will confuse end users and if they disable the instrumentation it will break their application. I am not keen on the if statements and would probably prefer mixing in separate modules depending on the gem versions but I'd like the original author @robertlaurin to weigh in on that. |
...umentation/active_record/lib/opentelemetry/instrumentation/active_record/patches/querying.rb
Outdated
Show resolved
Hide resolved
4d79b29
to
a35e2cb
Compare
…_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.
a35e2cb
to
8869502
Compare
:allow_retry
option to find_by_sql
patch:allow_retry
option to find_by_sql
patch
@@ -18,7 +18,7 @@ class << base | |||
|
|||
# Contains ActiveRecord::Querying to be patched | |||
module ClassMethods | |||
def find_by_sql(sql, binds = [], preparable: nil, &block) | |||
def find_by_sql(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there other methods here that need the same treatment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it does not look like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @andrewn617! Are there existing tests that cover this change?
@kaylareopelle I think now that we are just using |
Seems to me like we need to do something similar for these to future proof API changes: |
@andrewn617 I did miss @kaylareopelle comment about adding code coverage. Would you kindly add a test that uses |
hmmm actually this is edge rails so we cannot really test this at the moment. |
Rails 7.2 (rails/rails@eabcff2) introduces the
:allow_retry
option for thefind_by_sql
method, so we need to add it to this patch to maintain compatibility. The patch doesn't use the method's args, so we can just use(...)
to avoid this problem.To check the Rails version, I had to add rails as a development dependency. I added it in the gemspec and set the minimum version to 6.1 following the pattern I saw in the other libraries in this repo (for example).