-
Notifications
You must be signed in to change notification settings - Fork 598
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
Postgres and MySQL explain plan traces missing when agent is used with Rails v7.2+ #2922
Comments
The issue appears to be that See def get_explain_plan(statement)
connection = NewRelic::Agent::Database.get_connection(statement.config) do
::ActiveRecord::Base.send("#{statement.config[:adapter]}_connection",
statement.config)
end I'm not an The docs state:
It does appear the NewRelic agent tries to cache these connections itself, so there may be other options than leasing. Unless |
Thank you both bringing this to our attention, and for the detailed information about the problem. It does seem that this was something that was overlooked in our rails 7.2 support, so we will need to take a look at updating our instrumentation here to prevent this error in the future. |
Here's the relevant commit that removed the methods the agent has been relying on: |
The options that @gstark outlined seem great.
@ioquatix's Permanent Connection Checkout gist highlights the usage options nicely and even demonstrates invoking There are alternative approaches that I'm seeing to essentially still manually instantiate an adapter specific class and cache it, but I think when Rails v7.2+ is in play we should leverage |
Hi, @gsar and @gstark! @fallwith put together a fix for this bug that we'd like to get your feedback on. Would you be willing to test it out? If so, please update your Gemfile to install the # Gemfile
gem 'newrelic_rpm', github: 'newrelic/newrelic-ruby-agent', branch: 'how_will_we_ever_explain_this' |
@kaylareopelle - Hello, I am a colleague of @gstark. Apologies for missing your post asking for some testing help, but I did see the update was merged, so we updated |
Hi @jmoons! Thanks for checking in. Glad to hear you're not experiencing the error anymore, but I'm a little surprised. Though we've merged the related PR, we haven't included this code in a release yet. It should go out tomorrow as part of 9.16.0. Did you happen to disable explain plans while we were working on this fix (done by setting Can you confirm that you're also receiving explain plans in the New Relic UI? |
Description
We appear to be missing EXPLAIN traces for postgres queries with our instance.
Also seeing lots of these "undefined method postgresql_connection" being logged with ruby 3.3.5, rails 7.2.1.2 and newrelic_rpm 9.14.0.
Expected Behavior
There should be no errors in the logs.
Your Environment
See above for relevant version numbers. No changes in the environment were made besides upgrading ruby, rails and newrelic_rpm gem.
For Maintainers Only or Hero Triaging this bug
Suggested Priority (P1,P2,P3,P4,P5):
Suggested T-Shirt size (S, M, L, XL, Unknown):
The text was updated successfully, but these errors were encountered: