Log timeouts in addition to incrementing a counter to make it easier to get precise timestamps.
This commit is contained in:
parent
52078f7762
commit
4a4a721e90
|
@ -10,7 +10,6 @@ import io.lettuce.core.RedisCommandTimeoutException;
|
||||||
import io.lettuce.core.cluster.pubsub.StatefulRedisClusterPubSubConnection;
|
import io.lettuce.core.cluster.pubsub.StatefulRedisClusterPubSubConnection;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.textsecuregcm.util.CircuitBreakerUtil;
|
|
||||||
import org.whispersystems.textsecuregcm.util.Constants;
|
import org.whispersystems.textsecuregcm.util.Constants;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -20,6 +19,8 @@ import static com.codahale.metrics.MetricRegistry.name;
|
||||||
|
|
||||||
public class FaultTolerantPubSubConnection<K, V> {
|
public class FaultTolerantPubSubConnection<K, V> {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
private final StatefulRedisClusterPubSubConnection<K, V> pubSubConnection;
|
private final StatefulRedisClusterPubSubConnection<K, V> pubSubConnection;
|
||||||
|
|
||||||
private final CircuitBreaker circuitBreaker;
|
private final CircuitBreaker circuitBreaker;
|
||||||
|
@ -31,6 +32,7 @@ public class FaultTolerantPubSubConnection<K, V> {
|
||||||
private static final Logger log = LoggerFactory.getLogger(FaultTolerantPubSubConnection.class);
|
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) {
|
public FaultTolerantPubSubConnection(final String name, final StatefulRedisClusterPubSubConnection<K, V> pubSubConnection, final CircuitBreaker circuitBreaker, final Retry retry) {
|
||||||
|
this.name = name;
|
||||||
this.pubSubConnection = pubSubConnection;
|
this.pubSubConnection = pubSubConnection;
|
||||||
this.circuitBreaker = circuitBreaker;
|
this.circuitBreaker = circuitBreaker;
|
||||||
this.retry = retry;
|
this.retry = retry;
|
||||||
|
@ -50,6 +52,7 @@ public class FaultTolerantPubSubConnection<K, V> {
|
||||||
consumer.accept(pubSubConnection);
|
consumer.accept(pubSubConnection);
|
||||||
} catch (final RedisCommandTimeoutException e) {
|
} catch (final RedisCommandTimeoutException e) {
|
||||||
commandTimeoutMeter.mark();
|
commandTimeoutMeter.mark();
|
||||||
|
log.warn("Command timeout exception ({}-pubsub)", this.name, e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
@ -71,6 +74,7 @@ public class FaultTolerantPubSubConnection<K, V> {
|
||||||
return function.apply(pubSubConnection);
|
return function.apply(pubSubConnection);
|
||||||
} catch (final RedisCommandTimeoutException e) {
|
} catch (final RedisCommandTimeoutException e) {
|
||||||
commandTimeoutMeter.mark();
|
commandTimeoutMeter.mark();
|
||||||
|
log.warn("Command timeout exception ({}-pubsub)", this.name, e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -118,6 +118,7 @@ public class FaultTolerantRedisCluster {
|
||||||
consumer.accept(connection);
|
consumer.accept(connection);
|
||||||
} catch (final RedisCommandTimeoutException e) {
|
} catch (final RedisCommandTimeoutException e) {
|
||||||
commandTimeoutMeter.mark();
|
commandTimeoutMeter.mark();
|
||||||
|
log.warn("Command timeout exception ({})", this.name, e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
@ -139,6 +140,7 @@ public class FaultTolerantRedisCluster {
|
||||||
return function.apply(connection);
|
return function.apply(connection);
|
||||||
} catch (final RedisCommandTimeoutException e) {
|
} catch (final RedisCommandTimeoutException e) {
|
||||||
commandTimeoutMeter.mark();
|
commandTimeoutMeter.mark();
|
||||||
|
log.warn("Command timeout exception ({})", this.name, e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in New Issue