Skip to content

Commit

Permalink
Debug Redis calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBr committed Jan 11, 2024
1 parent c23168d commit 5038557
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ruby/lib/ci/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions ruby/lib/ci/queue/redis/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit 5038557

Please sign in to comment.