Skip to content

Commit

Permalink
Report unsuccessful queries in AsyncQueryForwardingServlet (apache#4143)
Browse files Browse the repository at this point in the history
  • Loading branch information
leventov authored and fjy committed Apr 4, 2017
1 parent 801ea5e commit 81ba022
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,7 @@ public void onComplete(Result result)
} 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(),
Expand Down Expand Up @@ -433,6 +427,7 @@ public void onFailure(Response response, Throwable failure)
try {
final String errorMessage = failure.getMessage();
failedQueryCount.incrementAndGet();
emitQueryTime(System.nanoTime() - startNs, false);
requestLogger.log(
new RequestLogLine(
new DateTime(),
Expand Down Expand Up @@ -461,5 +456,17 @@ public void onFailure(Response response, Throwable failure)

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);
}
}
}

0 comments on commit 81ba022

Please sign in to comment.