lib/sentry/redis.rb in sentry-ruby-5.7.0 vs lib/sentry/redis.rb in sentry-ruby-5.8.0
- old
+ new
@@ -52,11 +52,12 @@
end
def parsed_commands
commands.map do |statement|
command, key, *arguments = statement
- command_set = { command: command.to_s.upcase, key: key }
+ command_set = { command: command.to_s.upcase }
+ command_set[:key] = key if Utils::EncodingHelper.valid_utf_8?(key)
if Sentry.configuration.send_default_pii
command_set[:arguments] = arguments
.select { |a| Utils::EncodingHelper.valid_utf_8?(a) }
.join(" ")
@@ -68,21 +69,39 @@
def server_description
"#{host}:#{port}/#{db}"
end
- module Client
+ module OldClientPatch
def logging(commands, &block)
- Sentry::Redis.new(commands, host, port, db).instrument do
- super
- end
+ Sentry::Redis.new(commands, host, port, db).instrument { super }
end
end
+
+ module GlobalRedisInstrumentation
+ def call(command, redis_config)
+ Sentry::Redis
+ .new([command], redis_config.host, redis_config.port, redis_config.db)
+ .instrument { super }
+ end
+
+ def call_pipelined(commands, redis_config)
+ Sentry::Redis
+ .new(commands, redis_config.host, redis_config.port, redis_config.db)
+ .instrument { super }
+ end
+ end
end
end
if defined?(::Redis::Client)
- Sentry.register_patch do
- patch = Sentry::Redis::Client
- Redis::Client.prepend(patch) unless Redis::Client.ancestors.include?(patch)
+ if Gem::Version.new(::Redis::VERSION) < Gem::Version.new("5.0")
+ Sentry.register_patch do
+ patch = Sentry::Redis::OldClientPatch
+ unless Redis::Client.ancestors.include?(patch)
+ Redis::Client.prepend(patch)
+ end
+ end
+ elsif defined?(RedisClient)
+ RedisClient.register(Sentry::Redis::GlobalRedisInstrumentation)
end
end