Class: Airbrake::Rails::ActiveRecordSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake/rails/active_record_subscriber.rb

Overview

ActiveRecordSubscriber sends SQL information, including performance data.

Since:

  • v8.1.0

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object

Since:

  • v8.1.0



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/airbrake/rails/active_record_subscriber.rb', line 12

def call(*args)
  return unless Airbrake::Config.instance.query_stats

  routes = Airbrake::Rack::RequestStore[:routes]
  return if !routes || routes.none?

  event = Airbrake::Rails::Event.new(*args)
  frame = last_caller

  routes.each do |route, params|
    Airbrake.notify_query(
      route: route,
      method: params[:method],
      query: event.sql,
      func: frame[:function],
      file: frame[:file],
      line: frame[:line],
      timing: event.duration,
      time: event.time,
    )
  end
end