Sha256: a5b3fa3fbcccba7b6a626fa339bbe70e3addf964d4bd6c5d068de34deb21702b

Contents?: true

Size: 1.27 KB

Versions: 1

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 = common_attributes(event)
        payload = event.payload

        base.merge!({ "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

1 entries across 1 versions & 1 rubygems

Version Path
plain_apm-0.6.7 lib/plain_apm/hooks/active_support.rb