Add backtrace to ActiveRecord SQL queries
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
thanks for letting us know about this update in ActiveRecord, @pokonski! We'll take a look.