Class: Appsignal::Hooks::RedisHook

Inherits:
Hook
  • Object
show all
Defined in:
lib/appsignal/hooks/redis.rb

Instance Method Summary collapse

Methods inherited from Hook

#installed?, register, #try_to_install

Instance Method Details

#dependencies_present?Boolean

Returns:

  • (Boolean)

6
7
8
9
10
# File 'lib/appsignal/hooks/redis.rb', line 6

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

#installObject


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/appsignal/hooks/redis.rb', line 12

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

    def process(commands, &block)
      ActiveSupport::Notifications.instrument('query.redis') do
        process_without_appsignal(commands, &block)
      end
    end
  end
end