Skip to content

Commit

Permalink
Merge pull request #2161 from metamx/query-metrics-timeout
Browse files Browse the repository at this point in the history
Fix Query metrics for query timeout
  • Loading branch information
himanshug committed Jan 12, 2016
2 parents 9073e79 + 1bfb4e3 commit 01a0715
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public void onComplete(Result result)
requestTime,
"success",
result.isSucceeded()
&& result.getResponse().getStatus() == javax.ws.rs.core.Response.Status.OK.getStatusCode()
)
)
)
Expand Down
26 changes: 24 additions & 2 deletions server/src/main/java/io/druid/server/QueryResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ public void write(OutputStream outputStream) throws IOException, WebApplicationE
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())
Expand Down Expand Up @@ -236,13 +237,21 @@ public void write(OutputStream outputStream) throws IOException, WebApplicationE
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(),
req.getRemoteAddr(),
query,
new QueryStats(
ImmutableMap.<String, Object>of(
"query/time",
queryTime,
"success",
false,
"interrupted",
Expand Down Expand Up @@ -275,12 +284,25 @@ public void write(OutputStream outputStream) throws IOException, WebApplicationE
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.<String, Object>of("success", false, "exception", e.toString()))
new QueryStats(ImmutableMap.<String, Object>of(
"query/time",
queryTime,
"success",
false,
"exception",
e.toString()
))
)
);
}
Expand Down

0 comments on commit 01a0715

Please sign in to comment.