Sha256: 672a651af115cdee7fc8d09478c5c054aa2d6779d101cd04c5999842dd4fd987

Contents?: true

Size: 842 Bytes

Versions: 38

Compression:

Stored size: 842 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

        Appsignal::Environment.report_enabled("redis")
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
appsignal-2.11.10-java lib/appsignal/hooks/redis.rb
appsignal-2.11.10 lib/appsignal/hooks/redis.rb
appsignal-2.11.9-java lib/appsignal/hooks/redis.rb
appsignal-2.11.9 lib/appsignal/hooks/redis.rb
appsignal-2.11.8-java lib/appsignal/hooks/redis.rb
appsignal-2.11.8 lib/appsignal/hooks/redis.rb
appsignal-2.11.7 lib/appsignal/hooks/redis.rb
appsignal-2.11.7-java lib/appsignal/hooks/redis.rb
appsignal-2.11.6 lib/appsignal/hooks/redis.rb
appsignal-2.11.6-java lib/appsignal/hooks/redis.rb
appsignal-2.11.5-java lib/appsignal/hooks/redis.rb
appsignal-2.11.5 lib/appsignal/hooks/redis.rb
appsignal-2.11.4-java lib/appsignal/hooks/redis.rb
appsignal-2.11.4 lib/appsignal/hooks/redis.rb
appsignal-2.11.3-java lib/appsignal/hooks/redis.rb
appsignal-2.11.3 lib/appsignal/hooks/redis.rb
appsignal-2.11.2-java lib/appsignal/hooks/redis.rb
appsignal-2.11.2 lib/appsignal/hooks/redis.rb
appsignal-2.11.1-java lib/appsignal/hooks/redis.rb
appsignal-2.11.1 lib/appsignal/hooks/redis.rb