apm-agent-ruby icon indicating copy to clipboard operation
apm-agent-ruby copied to clipboard

Add backtrace to ActiveRecord SQL queries

Open pokonski opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

Currently Ruby agent does not submit backtraces for the SQL queries coming from Rails apps.

Describe the solution you'd like

Add backtraces to SQL queries so they are visible in Elastic APM UI.

Original request to Rails is here https://github.com/rails/rails/issues/37565 by @estolfo, but at that time it was not possible.

This is now possible using ActiveSupport::LogSubscriber where caller is available and returns proper backtrace with application sources.

ActiveRecord::LogSubscriber already does it to print out the line the query was called from. But full backtrace is also available, see how Rails does it here: https://github.com/rails/rails/blob/7-0-stable/activerecord/lib/active_record/log_subscriber.rb#L136

Describe alternatives you've considered

No alternatives

Additional context

pokonski avatar Sep 12 '23 08:09 pokonski

thanks for letting us know about this update in ActiveRecord, @pokonski! We'll take a look.

estolfo avatar Sep 13 '23 11:09 estolfo