Sha256: 1825f9b5e7a50dfcd6677bfb2e0712940dc7e62fc3b8f673fd7bd759de3447cb

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

require 'airbrake/rails/event'

module Airbrake
  module Rails
    # @since v8.3.0
    class ActionControllerPerformanceBreakdownSubscriber
      def call(*args)
        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,
            start_time: event.time
          }

          Airbrake.notify_performance_breakdown(breakdown_info, stash)
        end
      end

      private

      def build_stash
        stash = {}
        request = Airbrake::Rack::RequestStore[:request]
        return stash unless request

        stash[:request] = request
        if (user = Airbrake::Rack::User.extract(request.env))
          stash.merge!(user.as_json)
        end

        stash
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
airbrake-9.5.5 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.5.4 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.5.3 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.5.2 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.5.1 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.5.0 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.4.5 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.4.4 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.4.3 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.4.2 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.4.1 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.4.0 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.3.0 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb
airbrake-9.2.2 lib/airbrake/rails/action_controller_performance_breakdown_subscriber.rb