Log timeouts in addition to incrementing a counter to make it easier to get precise timestamps.

This commit is contained in:
Jon Chambers 2020-10-30 11:20:48 -04:00 committed by Jon Chambers
parent 52078f7762
commit 4a4a721e90
2 changed files with 7 additions and 1 deletions

View File

@ -10,7 +10,6 @@ import io.lettuce.core.RedisCommandTimeoutException;
import io.lettuce.core.cluster.pubsub.StatefulRedisClusterPubSubConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.util.CircuitBreakerUtil;
import org.whispersystems.textsecuregcm.util.Constants;
import java.util.function.Consumer;
@ -20,6 +19,8 @@ import static com.codahale.metrics.MetricRegistry.name;
public class FaultTolerantPubSubConnection<K, V> {
private final String name;
private final StatefulRedisClusterPubSubConnection<K, V> pubSubConnection;
private final CircuitBreaker circuitBreaker;
@ -31,6 +32,7 @@ public class FaultTolerantPubSubConnection<K, V> {
private static final Logger log = LoggerFactory.getLogger(FaultTolerantPubSubConnection.class);
public FaultTolerantPubSubConnection(final String name, final StatefulRedisClusterPubSubConnection<K, V> pubSubConnection, final CircuitBreaker circuitBreaker, final Retry retry) {
this.name = name;
this.pubSubConnection = pubSubConnection;
this.circuitBreaker = circuitBreaker;
this.retry = retry;
@ -50,6 +52,7 @@ public class FaultTolerantPubSubConnection<K, V> {
consumer.accept(pubSubConnection);
} catch (final RedisCommandTimeoutException e) {
commandTimeoutMeter.mark();
log.warn("Command timeout exception ({}-pubsub)", this.name, e);
throw e;
}
}));
@ -71,6 +74,7 @@ public class FaultTolerantPubSubConnection<K, V> {
return function.apply(pubSubConnection);
} catch (final RedisCommandTimeoutException e) {
commandTimeoutMeter.mark();
log.warn("Command timeout exception ({}-pubsub)", this.name, e);
throw e;
}
}));

View File

@ -118,6 +118,7 @@ public class FaultTolerantRedisCluster {
consumer.accept(connection);
} catch (final RedisCommandTimeoutException e) {
commandTimeoutMeter.mark();
log.warn("Command timeout exception ({})", this.name, e);
throw e;
}
}));
@ -139,6 +140,7 @@ public class FaultTolerantRedisCluster {
return function.apply(connection);
} catch (final RedisCommandTimeoutException e) {
commandTimeoutMeter.mark();
log.warn("Command timeout exception ({})", this.name, e);
throw e;
}
}));