+ private static final class AskTimeoutCounter extends OnComplete<Object> implements ExecutionContext {
+ private LongAdder ateExceptions = new LongAdder();
+
+ @Override
+ public void onComplete(final Throwable failure, final Object success) throws Throwable {
+ if (failure instanceof AskTimeoutException) {
+ ateExceptions.increment();
+ }
+ }
+
+ void reset() {
+ ateExceptions = new LongAdder();
+ }
+
+ long sum() {
+ return ateExceptions.sum();
+ }
+
+ @Override
+ public void execute(final Runnable runnable) {
+ // Yes, we are this ugly, but then we are just doing a check + an increment
+ runnable.run();
+ }
+
+ @Override
+ public void reportFailure(final Throwable cause) {
+ LOG.warn("Unexpected failure updating counters", cause);
+ }
+ }
+