mirror of https://github.com/apache/druid.git
Merge pull request #2150 from himanshug/emit_query_bytes
emit query/bytes metric
This commit is contained in:
commit
3c107c5757
|
@ -29,8 +29,9 @@ Available Metrics
|
|||
|Metric|Description|Dimensions|Normal Value|
|
||||
|------|-----------|----------|------------|
|
||||
|`query/time`|Milliseconds taken to complete a query.|Common: dataSource, type, interval, hasFilters, duration, context, remoteAddress, id. Aggregation Queries: numMetrics, numComplexMetrics. GroupBy: numDimensions. TopN: threshold, dimension.|< 1s|
|
||||
|`query/bytes`|number of bytes returned in query response.|Common: dataSource, type, interval, hasFilters, duration, context, remoteAddress, id. Aggregation Queries: numMetrics, numComplexMetrics. GroupBy: numDimensions. TopN: threshold, dimension.| |
|
||||
|`query/node/time`|Milliseconds taken to query individual historical/realtime nodes.|id, status, server.|< 1s|
|
||||
|`query/node/bytes`|bytes returned from querying individual historical/realtime nodes.|id, status, server.| |
|
||||
|`query/node/bytes`|number of bytes returned from querying individual historical/realtime nodes.|id, status, server.| |
|
||||
|`query/node/ttfb`|Time to first byte. Milliseconds elapsed until broker starts receiving the response from individual historical/realtime nodes.|id, status, server.|< 1s|
|
||||
|`query/intervalChunk/time`|Only emitted if interval chunking is enabled. Milliseconds required to query an interval chunk.|id, status, chunkInterval (if interval chunking is enabled).|< 1s|
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.fasterxml.jackson.jaxrs.smile.SmileMediaTypes;
|
|||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.io.CountingOutputStream;
|
||||
import com.google.inject.Inject;
|
||||
import com.metamx.common.guava.Sequence;
|
||||
import com.metamx.common.guava.Sequences;
|
||||
|
@ -184,15 +185,21 @@ public class QueryResource
|
|||
public void write(OutputStream outputStream) throws IOException, WebApplicationException
|
||||
{
|
||||
// json serializer will always close the yielder
|
||||
jsonWriter.writeValue(outputStream, yielder);
|
||||
outputStream.flush(); // Some types of OutputStream suppress flush errors in the .close() method.
|
||||
outputStream.close();
|
||||
CountingOutputStream os = new CountingOutputStream(outputStream);
|
||||
jsonWriter.writeValue(os, yielder);
|
||||
|
||||
os.flush(); // Some types of OutputStream suppress flush errors in the .close() method.
|
||||
os.close();
|
||||
|
||||
final long queryTime = System.currentTimeMillis() - start;
|
||||
emitter.emit(
|
||||
DruidMetrics.makeQueryTimeMetric(jsonMapper, theQuery, req.getRemoteAddr())
|
||||
.build("query/time", queryTime)
|
||||
);
|
||||
emitter.emit(
|
||||
DruidMetrics.makeQueryTimeMetric(jsonMapper, theQuery, req.getRemoteAddr())
|
||||
.build("query/bytes", os.getCount())
|
||||
);
|
||||
|
||||
requestLogger.log(
|
||||
new RequestLogLine(
|
||||
|
@ -202,6 +209,7 @@ public class QueryResource
|
|||
new QueryStats(
|
||||
ImmutableMap.<String, Object>of(
|
||||
"query/time", queryTime,
|
||||
"query/bytes", os.getCount(),
|
||||
"success", true
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue