lib/ci/queue/redis/base.rb in ci-queue-0.57.0 vs lib/ci/queue/redis/base.rb in ci-queue-0.58.0

- old
+ new

@@ -11,20 +11,22 @@ ::SocketError, # https://github.com/redis/redis-rb/pull/631 ].freeze module RedisInstrumentation def call(command, redis_config) - result = super logger = redis_config.custom[:debug_log] - logger.info("#{command}: #{result}") + logger.info("Running '#{command}'") + result = super + logger.info("Finished '#{command}': #{result}") result end def call_pipelined(commands, redis_config) - result = super logger = redis_config.custom[:debug_log] - logger.info("#{commands}: #{result}") + logger.info("Running '#{commands}'") + result = super + logger.info("Finished '#{commands}': #{result}") result end end def initialize(redis_url, config) @@ -182,9 +184,23 @@ end private attr_reader :redis, :redis_url + + def with_redis_timeout(timeout) + prev = redis._client.timeout + redis._client.timeout = timeout + yield + ensure + redis._client.timeout = prev + end + + def measure + starting = Process.clock_gettime(Process::CLOCK_MONOTONIC) + yield + Process.clock_gettime(Process::CLOCK_MONOTONIC) - starting + end def key(*args) ['build', build_id, *args].join(':') end