lib/instana/activators/redis.rb in instana-1.213.3 vs lib/instana/activators/redis.rb in instana-1.214.0
- old
+ new
@@ -3,16 +3,21 @@
module Instana
module Activators
class Redis < Activator
def can_instrument?
- defined?(::Redis) && defined?(::Redis::Client) && ::Instana.config[:redis][:enabled]
+ defined?(::Redis) && defined?(::Redis::Client) && ::Instana.config[:redis][:enabled] &&
+ (Gem::Specification.find_by_name('redis').version < Gem::Version.new('5.0') || defined?(::RedisClient))
end
def instrument
require 'instana/instrumentation/redis'
- ::Redis::Client.prepend(::Instana::RedisInstrumentation)
+ if Gem::Specification.find_by_name('redis').version >= Gem::Version.new('5.0')
+ ::RedisClient.prepend(::Instana::RedisInstrumentation)
+ else
+ ::Redis::Client.prepend(::Instana::RedisInstrumentation)
+ end
true
end
end
end