Class: Airbrake::Rails::ActionControllerPerformanceBreakdownSubscriber

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

Overview

Since:

  • v8.3.0

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object

Since:

  • v8.3.0



9
10
11
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/action_controller_performance_breakdown_subscriber.rb', line 9

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

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

  event = Airbrake::Rails::Event.new(*args)
  stash = build_stash

  routes.each do |route, params|
    groups = event.groups.merge(params[:groups])
    next if groups.none?

    breakdown_info = {
      method: event.method,
      route: route,
      response_type: event.response_type,
      groups: groups,
      timing: event.duration,
      time: event.time,
    }

    Airbrake.notify_performance_breakdown(breakdown_info, stash)
  end
end