Sha256: fef4230dc750e330354e71eddf62bd784e498977b45c3bcdd7439c26ab818e63

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module PlainApm
  module Hooks
    class ActionPack < ActiveSupportSubscriber
      NOTIFICATION_PATTERN = /\A[^!]\w+\.action_controller\Z/.freeze

      private

      def notification_pattern
        NOTIFICATION_PATTERN
      end

      def payload(event)
        name, base = attributes_from_notification(event)
        payload = event.payload

        case name
        when "process_action"
          base.tap do |o|
            o[:controller] = payload[:controller]
            o[:action] = payload[:action]
            o[:params] = payload[:params]
            o[:format] = payload[:format]
            o[:method] = payload[:method]
            o[:path] = payload[:path]
            o[:status] = payload[:status]
          end
        when "start_processing"
          base.tap do |o|
            o[:controller] = payload[:controller]
            o[:action] = payload[:action]
          end
        when "redirect_to", "halted_callback", "send_file", "send_data"
          nil
        when "read_fragment", "write_fragment", "exist_fragment?", "expire_fragment"
          # controller, action, key
          nil
        else
          nil
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plain_apm-0.10.2 lib/plain_apm/hooks/action_pack.rb