From 2db3144f04c4d2e1dbe09a10bd6efec8b62f43d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20L=C3=A9aut=C3=A9?= Date: Mon, 9 Feb 2015 16:41:30 -0800 Subject: [PATCH] fix change in request/time meaning introduced by d2c729a, fixed #1102 --- .../java/io/druid/server/QueryResource.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/server/src/main/java/io/druid/server/QueryResource.java b/server/src/main/java/io/druid/server/QueryResource.java index 1a1e57b4a49..4df41d37828 100644 --- a/server/src/main/java/io/druid/server/QueryResource.java +++ b/server/src/main/java/io/druid/server/QueryResource.java @@ -117,7 +117,7 @@ public class QueryResource public Response doPost( InputStream in, @QueryParam("pretty") String pretty, - @Context HttpServletRequest req // used only to get request content-type and remote address + @Context final HttpServletRequest req // used only to get request content-type and remote address ) throws IOException { final long start = System.currentTimeMillis(); @@ -176,27 +176,7 @@ public class QueryResource ); try { - long requestTime = System.currentTimeMillis() - start; - - emitter.emit( - QueryMetricUtil.makeRequestTimeMetric(jsonMapper, query, req.getRemoteAddr()) - .build("request/time", requestTime) - ); - - requestLogger.log( - new RequestLogLine( - new DateTime(), - req.getRemoteAddr(), - query, - new QueryStats( - ImmutableMap.of( - "request/time", requestTime, - "success", true - ) - ) - ) - ); - + final Query theQuery = query; return Response .ok( new StreamingOutput() @@ -207,6 +187,26 @@ public class QueryResource // json serializer will always close the yielder jsonWriter.writeValue(outputStream, yielder); outputStream.close(); + + final long requestTime = System.currentTimeMillis() - start; + emitter.emit( + QueryMetricUtil.makeRequestTimeMetric(jsonMapper, theQuery, req.getRemoteAddr()) + .build("request/time", requestTime) + ); + + requestLogger.log( + new RequestLogLine( + new DateTime(), + req.getRemoteAddr(), + theQuery, + new QueryStats( + ImmutableMap.of( + "request/time", requestTime, + "success", true + ) + ) + ) + ); } }, contentType