Sha256: 0e7309297ee8e43fbc118a32df8847fbb13ac164661d37a418925d20ca11a392

Contents?: true

Size: 1.31 KB

Versions: 14

Compression:

Stored size: 1.31 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, source = *event.name.split(".")
        payload = event.payload

        base = {
          "source" => source,
          "name" => name,
          "backtrace" => filtered_backtrace,
          "allocations" => event.allocations,
          "thread_allocations" => event.thread_allocations,
          "started_at" => event.time,
          "finished_at" => event.end
        }

        case name
        when "process_action"
          base.merge({
            "controller" => payload[:controller],
            "action" => payload[:action],
            "params" => payload[:params],
            "format" => payload[:format],
            "method" => payload[:method],
            "path" => payload[:path],
            "status" => payload[:status]
          })
        when "redirect_to", "start_processing", "halted_callback", "send_file", "send_data"
          nil
        when "read_fragment", "write_fragment", "exist_fragment?", "expire_fragment"
          # controller, action, key
          nil
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
plain_apm-0.6.6 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.6.5 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.6.4 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.6.3 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.6.2 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.6.1 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.5.7 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.5.6 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.5.5 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.5.4 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.5.3 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.5.2 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.5.1 lib/plain_apm/hooks/action_pack.rb
plain_apm-0.5.0 lib/plain_apm/hooks/action_pack.rb