From 81ba0224c50c2eaad489e33f2b30e3b6e60ca95a Mon Sep 17 00:00:00 2001 From: Roman Leventov Date: Tue, 4 Apr 2017 15:53:07 -0500 Subject: [PATCH] Report unsuccessful queries in AsyncQueryForwardingServlet (#4143) --- .../server/AsyncQueryForwardingServlet.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java b/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java index 20a54c9f376..6bc71cc6040 100644 --- a/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java +++ b/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java @@ -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); + } } }