fix change in request/time meaning introduced by d2c729a, fixed #1102

This commit is contained in:
Xavier Léauté 2015-02-09 16:41:30 -08:00
parent 1ee4f7cc13
commit 2db3144f04
1 changed files with 22 additions and 22 deletions

View File

@ -117,7 +117,7 @@ public class QueryResource
public Response doPost( public Response doPost(
InputStream in, InputStream in,
@QueryParam("pretty") String pretty, @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 ) throws IOException
{ {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
@ -176,27 +176,7 @@ public class QueryResource
); );
try { try {
long requestTime = System.currentTimeMillis() - start; final Query theQuery = query;
emitter.emit(
QueryMetricUtil.makeRequestTimeMetric(jsonMapper, query, req.getRemoteAddr())
.build("request/time", requestTime)
);
requestLogger.log(
new RequestLogLine(
new DateTime(),
req.getRemoteAddr(),
query,
new QueryStats(
ImmutableMap.<String, Object>of(
"request/time", requestTime,
"success", true
)
)
)
);
return Response return Response
.ok( .ok(
new StreamingOutput() new StreamingOutput()
@ -207,6 +187,26 @@ public class QueryResource
// json serializer will always close the yielder // json serializer will always close the yielder
jsonWriter.writeValue(outputStream, yielder); jsonWriter.writeValue(outputStream, yielder);
outputStream.close(); 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.<String, Object>of(
"request/time", requestTime,
"success", true
)
)
)
);
} }
}, },
contentType contentType