Sha256: 8781509e9a76bf767cb58926f0ab484d4e69156e5e40d67c9a9cd534dc48d07f

Contents?: true

Size: 786 Bytes

Versions: 122

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

module Appsignal
  class Hooks
    # @api private
    class RedisHook < Appsignal::Hooks::Hook
      register :redis

      def dependencies_present?
        defined?(::Redis) &&
          Appsignal.config &&
          Appsignal.config[:instrument_redis]
      end

      def install
        ::Redis::Client.class_eval do
          alias process_without_appsignal process

          def process(commands, &block)
            sanitized_commands = commands.map do |command, *args|
              "#{command}#{" ?" * args.size}"
            end.join("\n")

            Appsignal.instrument "query.redis", id, sanitized_commands do
              process_without_appsignal(commands, &block)
            end
          end
        end
      end
    end
  end
end

Version data entries

122 entries across 122 versions & 1 rubygems

Version Path
appsignal-2.10.12 lib/appsignal/hooks/redis.rb
appsignal-2.10.12-java lib/appsignal/hooks/redis.rb
appsignal-2.10.11 lib/appsignal/hooks/redis.rb
appsignal-2.10.11-java lib/appsignal/hooks/redis.rb
appsignal-2.10.10 lib/appsignal/hooks/redis.rb
appsignal-2.10.10-java lib/appsignal/hooks/redis.rb
appsignal-2.10.9 lib/appsignal/hooks/redis.rb
appsignal-2.10.9-java lib/appsignal/hooks/redis.rb
appsignal-2.10.9.beta.1-java lib/appsignal/hooks/redis.rb
appsignal-2.10.9.beta.1 lib/appsignal/hooks/redis.rb
appsignal-2.10.8 lib/appsignal/hooks/redis.rb
appsignal-2.10.8-java lib/appsignal/hooks/redis.rb
appsignal-2.10.7-java lib/appsignal/hooks/redis.rb
appsignal-2.10.7 lib/appsignal/hooks/redis.rb
appsignal-2.10.6-java lib/appsignal/hooks/redis.rb
appsignal-2.10.6 lib/appsignal/hooks/redis.rb
appsignal-2.10.6.beta.1-java lib/appsignal/hooks/redis.rb
appsignal-2.10.6.beta.1 lib/appsignal/hooks/redis.rb
appsignal-2.10.5-java lib/appsignal/hooks/redis.rb
appsignal-2.10.5 lib/appsignal/hooks/redis.rb