Report unsuccessful queries in AsyncQueryForwardingServlet (#4143)

This commit is contained in:
Roman Leventov 2017-04-04 15:53:07 -05:00 committed by Fangjin Yang
parent 801ea5efa4
commit 81ba0224c5
1 changed files with 14 additions and 7 deletions

View File

@ -394,13 +394,7 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet implements Qu
} else {
failedQueryCount.incrementAndGet();
}
QueryMetrics queryMetrics = DruidMetrics.makeRequestMetrics(
queryMetricsFactory,
warehouse.getToolChest(query),
query,
req.getRemoteAddr()
);
queryMetrics.reportQueryTime(requestTimeNs).emit(emitter);
emitQueryTime(requestTimeNs, success);
requestLogger.log(
new RequestLogLine(
new DateTime(),
@ -433,6 +427,7 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet implements Qu
try {
final String errorMessage = failure.getMessage();
failedQueryCount.incrementAndGet();
emitQueryTime(System.nanoTime() - startNs, false);
requestLogger.log(
new RequestLogLine(
new DateTime(),
@ -461,5 +456,17 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet implements Qu
super.onFailure(response, failure);
}
private void emitQueryTime(long requestTimeNs, boolean success) throws JsonProcessingException
{
QueryMetrics queryMetrics = DruidMetrics.makeRequestMetrics(
queryMetricsFactory,
warehouse.getToolChest(query),
query,
req.getRemoteAddr()
);
queryMetrics.success(success);
queryMetrics.reportQueryTime(requestTimeNs).emit(emitter);
}
}
}