Query should not fail because emitter fails or throws Exception (#5484)

This commit is contained in:
Niketh Sabbineni 2018-03-13 19:57:05 -07:00 committed by Slim
parent 9b2a25bd84
commit 40cc2c8740
1 changed files with 9 additions and 1 deletions

View File

@ -19,6 +19,7 @@
package io.druid.query;
import io.druid.java.util.common.logger.Logger;
import io.druid.java.util.emitter.service.ServiceEmitter;
import io.druid.java.util.common.guava.LazySequence;
import io.druid.java.util.common.guava.Sequence;
@ -39,6 +40,7 @@ public class MetricsEmittingQueryRunner<T> implements QueryRunner<T>
private final long creationTimeNs;
private final ObjLongConsumer<? super QueryMetrics<?>> reportMetric;
private final Consumer<QueryMetrics<?>> applyCustomDimensions;
private static final Logger log = new Logger(MetricsEmittingQueryRunner.class);
private MetricsEmittingQueryRunner(
ServiceEmitter emitter,
@ -117,7 +119,13 @@ public class MetricsEmittingQueryRunner<T> implements QueryRunner<T>
if (creationTimeNs > 0) {
queryMetrics.reportWaitTime(startTimeNs - creationTimeNs);
}
queryMetrics.emit(emitter);
try {
queryMetrics.emit(emitter);
}
catch (Exception e) {
// Query should not fail, because of emitter failure. Swallowing the exception.
log.error("Failure while trying to emit [%s] with stacktrace [%s]", emitter.toString(), e);
}
}
}
);