Class: Airbrake::Rails::ActionControllerNotifySubscriber
- Inherits:
-
Object
- Object
- Airbrake::Rails::ActionControllerNotifySubscriber
- Defined in:
- lib/airbrake/rails/action_controller_notify_subscriber.rb
Overview
ActionControllerNotifySubscriber sends route stat information, including performance data.
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(rails_vsn) ⇒ ActionControllerNotifySubscriber
constructor
A new instance of ActionControllerNotifySubscriber.
Constructor Details
#initialize(rails_vsn) ⇒ ActionControllerNotifySubscriber
Returns a new instance of ActionControllerNotifySubscriber.
12 13 14 |
# File 'lib/airbrake/rails/action_controller_notify_subscriber.rb', line 12 def initialize(rails_vsn) @rails_7_or_above = rails_vsn.to_i >= 7 end |
Instance Method Details
#call(*args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/airbrake/rails/action_controller_notify_subscriber.rb', line 16 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) routes.each do |route, _params| Airbrake.notify_request( method: event.method, route: route, status_code: event.status_code, timing: event.duration, # On Rails 7+ `ActiveSupport::Notifications::Event#time` returns an # instance of Float. It represents monotonic time in milliseconds. # Airbrake Ruby expects that the provided time is in seconds. Hence, # we need to convert it from milliseconds to seconds. In the # versions below Rails 7, time is an instance of Time. # # Relevant commit: # https://github.com/rails/rails/commit/81d0dc90becfe0b8e7f7f26beb66c25d84b8ec7f time: @rails_7_or_above ? event.time / 1000 : event.time, ) end end |