Sha256: ab5fb222e364754877fed11630efb318b68fd129183bab40df04054fea86ff96

Contents?: true

Size: 1.27 KB

Versions: 14

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module PlainApm
  module Hooks
    class ActiveSupport < ActiveSupportSubscriber
      NOTIFICATION_PATTERN = /\Acache_[\w?]+\.active_support\Z/.freeze

      private

      def notification_pattern
        NOTIFICATION_PATTERN
      end

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

        base["store"] = payload[:store]

        case name
        when "cache_read"
          base.merge({
            "key" => payload[:key],
            "hit" => payload[:hit],
            "trigger" => payload[:super_operation]
          })
        when "cache_read_multi"
          base.merge({
            "keys" => payload[:key],
            "hits" => payload[:hits]
          })
        when "cache_fetch_hit"
          base.merge({
            "key" => payload[:key],
            "hit" => true
          })
        when "cache_write", "cache_write_multi", "cache_generate", "cache_delete", "cache_delete_matched", "cache_exist?"
          base.merge({
            "key" => payload[:key]
          })
        when "cache_increment", "cache_decrement"
          base.merge({
            "key" => payload[:key],
            "amount" => payload[:amount]
          })
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
plain_apm-0.9.2 lib/plain_apm/hooks/active_support.rb
plain_apm-0.9.1 lib/plain_apm/hooks/active_support.rb
plain_apm-0.9.0 lib/plain_apm/hooks/active_support.rb
plain_apm-0.8.8 lib/plain_apm/hooks/active_support.rb
plain_apm-0.8.7 lib/plain_apm/hooks/active_support.rb
plain_apm-0.8.6 lib/plain_apm/hooks/active_support.rb
plain_apm-0.8.5 lib/plain_apm/hooks/active_support.rb
plain_apm-0.8.4 lib/plain_apm/hooks/active_support.rb
plain_apm-0.8.3 lib/plain_apm/hooks/active_support.rb
plain_apm-0.8.2 lib/plain_apm/hooks/active_support.rb
plain_apm-0.8.1 lib/plain_apm/hooks/active_support.rb
plain_apm-0.8.0 lib/plain_apm/hooks/active_support.rb
plain_apm-0.7.1 lib/plain_apm/hooks/active_support.rb
plain_apm-0.7.0 lib/plain_apm/hooks/active_support.rb