Sha256: 5162decb63f3b603170f52594a2eebfd91d3a5a31acdda3d1d2fc17fb5d83e4a

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 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.tap do |o|
            o[:key] = payload[:key]
            o[:hit] = payload[:hit]
            o[:trigger] = payload[:super_operation]
          end
        when "cache_read_multi"
          base.tap do |o|
            o[:keys] = payload[:key]
            o[:hits] = payload[:hits]
          end
        when "cache_fetch_hit"
          base.tap do |o|
            o[:key] = payload[:key]
            o[:hit] = true
          end
        when "cache_write", "cache_write_multi", "cache_generate", "cache_delete", "cache_delete_matched", "cache_exist?"
          base.tap do |o|
            o[:key] = payload[:key]
          end
        when "cache_increment", "cache_decrement"
          base.tap do |o|
            o[:key] = payload[:key]
            o[:amount] = payload[:amount]
          end
        else
          nil
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
plain_apm-0.10.2 lib/plain_apm/hooks/active_support.rb
plain_apm-0.10.0 lib/plain_apm/hooks/active_support.rb
plain_apm-0.9.8 lib/plain_apm/hooks/active_support.rb
plain_apm-0.9.7 lib/plain_apm/hooks/active_support.rb
plain_apm-0.9.6 lib/plain_apm/hooks/active_support.rb
plain_apm-0.9.5 lib/plain_apm/hooks/active_support.rb
plain_apm-0.9.4 lib/plain_apm/hooks/active_support.rb
plain_apm-0.9.3 lib/plain_apm/hooks/active_support.rb