From 50385576503d027525088e8e47401c7e1db7d6ab Mon Sep 17 00:00:00 2001 From: Christian Bruckmayer Date: Thu, 11 Jan 2024 21:20:05 +0000 Subject: [PATCH] Debug Redis calls --- ruby/lib/ci/queue.rb | 7 +++++++ ruby/lib/ci/queue/redis/base.rb | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ruby/lib/ci/queue.rb b/ruby/lib/ci/queue.rb index f849a660..fc9b8f55 100644 --- a/ruby/lib/ci/queue.rb +++ b/ruby/lib/ci/queue.rb @@ -24,6 +24,13 @@ module Warnings RESERVED_LOST_TEST = :RESERVED_LOST_TEST end + def logger + @logger ||= begin + FileUtils.mkdir_p("log") + Logger.new('log/ci-queue.log') + end + end + def requeueable?(test_result) requeueable.nil? || requeueable.call(test_result) end diff --git a/ruby/lib/ci/queue/redis/base.rb b/ruby/lib/ci/queue/redis/base.rb index dd073239..04c074b4 100644 --- a/ruby/lib/ci/queue/redis/base.rb +++ b/ruby/lib/ci/queue/redis/base.rb @@ -11,6 +11,20 @@ class Base ::SocketError, # https://github.com/redis/redis-rb/pull/631 ].freeze + module RedisInstrumentation + def call(command, redis_config) + result = super + CI::Queue.logger.info("#{command}: #{result}") if ENV['CI_QUEUE_DEBUG'] + result + end + + def call_pipelined(commands, redis_config) + result = super + CI::Queue.logger.info("#{command}: #{result}") if ENV['CI_QUEUE_DEBUG'] + result + end + end + def initialize(redis_url, config) @redis_url = redis_url if ::Redis::VERSION > "5.0.0" @@ -19,6 +33,7 @@ def initialize(redis_url, config) # Booting a CI worker is costly, so in case of a Redis blip, # it makes sense to retry for a while before giving up. reconnect_attempts: [0, 0, 0.1, 0.5, 1, 3, 5], + middlewares: [RedisInstrumentation] ) else @redis = ::Redis.new(url: redis_url)