From 1bfb4e3988323aedd974d1502a639d49a4fb2f6b Mon Sep 17 00:00:00 2001 From: Nishant Date: Thu, 24 Dec 2015 12:07:00 +0530 Subject: [PATCH] Emit query/time for failed and timeout queries emit query/time metric also add success flag fix success flag for router metrics review comments formatting. --- .../server/AsyncQueryForwardingServlet.java | 1 + .../java/io/druid/server/QueryResource.java | 26 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java b/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java index dc4116e1b8f..b7a9057b92a 100644 --- a/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java +++ b/server/src/main/java/io/druid/server/AsyncQueryForwardingServlet.java @@ -322,6 +322,7 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet requestTime, "success", result.isSucceeded() + && result.getResponse().getStatus() == javax.ws.rs.core.Response.Status.OK.getStatusCode() ) ) ) diff --git a/server/src/main/java/io/druid/server/QueryResource.java b/server/src/main/java/io/druid/server/QueryResource.java index 0ebe1b52d51..e75030bccb0 100644 --- a/server/src/main/java/io/druid/server/QueryResource.java +++ b/server/src/main/java/io/druid/server/QueryResource.java @@ -194,7 +194,8 @@ public class QueryResource final long queryTime = System.currentTimeMillis() - start; emitter.emit( DruidMetrics.makeQueryTimeMetric(jsonMapper, theQuery, req.getRemoteAddr()) - .build("query/time", queryTime) + .setDimension("success", "true") + .build("query/time", queryTime) ); emitter.emit( DruidMetrics.makeQueryTimeMetric(jsonMapper, theQuery, req.getRemoteAddr()) @@ -236,6 +237,12 @@ public class QueryResource catch (QueryInterruptedException e) { try { log.info("%s [%s]", e.getMessage(), queryId); + final long queryTime = System.currentTimeMillis() - start; + emitter.emit( + DruidMetrics.makeQueryTimeMetric(jsonMapper, query, req.getRemoteAddr()) + .setDimension("success", "false") + .build("query/time", queryTime) + ); requestLogger.log( new RequestLogLine( new DateTime(), @@ -243,6 +250,8 @@ public class QueryResource query, new QueryStats( ImmutableMap.of( + "query/time", + queryTime, "success", false, "interrupted", @@ -275,12 +284,25 @@ public class QueryResource log.warn(e, "Exception occurred on request [%s]", queryString); try { + final long queryTime = System.currentTimeMillis() - start; + emitter.emit( + DruidMetrics.makeQueryTimeMetric(jsonMapper, query, req.getRemoteAddr()) + .setDimension("success", "false") + .build("query/time", queryTime) + ); requestLogger.log( new RequestLogLine( new DateTime(), req.getRemoteAddr(), query, - new QueryStats(ImmutableMap.of("success", false, "exception", e.toString())) + new QueryStats(ImmutableMap.of( + "query/time", + queryTime, + "success", + false, + "exception", + e.toString() + )) ) ); }