Package org.apache.druid.query
Class DefaultQueryMetrics<QueryType extends Query<?>>
java.lang.Object
org.apache.druid.query.DefaultQueryMetrics<QueryType>
- All Implemented Interfaces:
QueryMetrics<QueryType>
- Direct Known Subclasses:
DefaultGroupByQueryMetrics,DefaultTimeseriesQueryMetrics,DefaultTopNQueryMetrics
public class DefaultQueryMetrics<QueryType extends Query<?>>
extends Object
implements QueryMetrics<QueryType>
DefaultQueryMetrics is unsafe for use from multiple threads. It fails with RuntimeException on access not from the
thread where it was constructed. To "transfer" DefaultQueryMetrics from one thread to another
ownerThread
field should be updated.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ServiceMetricEvent.Builderprotected ThreadNon final to give subclasses ability to reassign it.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidSetsQuery.getContext()of the given query as dimension.voiddataSource(QueryType query) SetsQuery.getDataSource()of the given query as dimension.voidSetsQuery.getDuration()of the given query as dimension.voidemit(ServiceEmitter emitter) Emits all metrics, registered since the lastemit()call on this QueryMetrics object.static String[]getIntervalsAsStringArray(Collection<org.joda.time.Interval> intervals) static StringgetTableNamesAsString(Set<String> tableNames) voidhasFilters(QueryType query) SetsQuery.hasFilters()of the given query as dimension.voidSets identity of the requester for a query.voidSetsQuery.getIntervals()of the given query as dimension.makeBitmapResultFactory(BitmapFactory factory) Creates aBitmapResultFactorywhich may record some information along bitmap construction fromQueryMetrics.filterBundle(FilterBundle.BundleInfo).voidparallelMergeParallelism(int parallelism) Sets broker merge parallelism, if parallel merges are enabled.voidprojection(String projection) If a projection was used during segment processing, set its name as the projection dimensionvoidPulls all information from the query object into dimensions of future metrics.voidSets id of the given query as dimension.voidSetsQuery.getId()of the given query as dimension.voidSetsQuery.getType()of the given query as dimension.voidremoteAddress(String remoteAddress) reportBackPressureTime(long timeNs) Registers "time that channel is unreadable (backpressure)" metric.reportBitmapConstructionTime(long timeNs) Reports the time spent constructing bitmap fromQueryMetrics.filterBundle(FilterBundle.BundleInfo)of the query.reportCpuTime(long timeNs) Registers "cpu time" metric.protected QueryMetrics<QueryType>reportMetric(String metricName, Number value) reportNodeBytes(long byteCount) Registers "node bytes" metric.reportNodeTime(long timeNs) Registers "node time" metric.reportNodeTimeToFirstByte(long timeNs) Registers "time to first byte" metric.reportParallelMergeFastestPartitionTime(long timeNs) Reports broker "wall" time in nanoseconds for the fastest parallel merge sequence partition to be 'initialized', where 'initialized' is time to the first result batch is populated from data servers and merging can begin.reportParallelMergeInputRows(long numRows) Reports total number of input rows processed by the broker during parallel merge.reportParallelMergeInputSequences(long numSequences) Reports total number of input sequences processed by the broker during parallel merge.reportParallelMergeOutputRows(long numRows) Reports broker total number of output rows after merging and combining input sequences (should be less than or equal to the value supplied toQueryMetrics.reportParallelMergeInputRows(long).reportParallelMergeParallelism(int parallelism) Reports number of parallel tasks the broker used to process the query during parallel merge.reportParallelMergeSlowestPartitionTime(long timeNs) Reports broker "wall" time in nanoseconds for the slowest parallel merge sequence partition to be 'initialized', where 'initialized' is time to the first result batch is populated from data servers and merging can begin.reportParallelMergeTaskCount(long numTasks) Reports broker total number of fork join pool tasks required to complete queryreportParallelMergeTotalCpuTime(long timeNs) Reports broker total CPU time in nanoseconds where fork join merge combine tasks were doing workreportParallelMergeTotalTime(long timeNs) Reports broker total "wall" time in nanoseconds from parallel merge start sequence creation to total consumption.reportPreFilteredRows(long numRows) Reports the number of rows to scan in the segment after applyingQueryMetrics.filterBundle(FilterBundle.BundleInfo).reportQueriedSegmentCount(long segmentCount) Registers "segments queried count" metric.reportQueryBytes(long byteCount) Registers "query bytes" metric.reportQueryTime(long timeNs) Registers "query time" metric.reportResultCachePoll(boolean hit) Emits iff a given query polled the result-level cache and the success of that operation.reportSegmentAndCacheTime(long timeNs) Registers "segmentAndCache time" metric.reportSegmentOnDemandLoadBytes(long byteCount) Registers the total number of bytes added to the cache when loading segments on demand, summing the sizes loaded by individual segement load threads.reportSegmentOnDemandLoadCount(long count) Registers the total numer of segments loaded on demand.reportSegmentOnDemandLoadTime(long timeNs) Registers the apparent time spent loading segments on demand, before queing up for processing.reportSegmentOnDemandLoadTimeAvg(long timeNs) Registers the average time spent loading segments on demand across threads.reportSegmentOnDemandLoadTimeMax(long timeNs) Registers the maximum time spent waiting for a thread to start loading segments on demand across all load threads.reportSegmentOnDemandLoadWaitTimeAvg(long timeNs) Registers the average time spent waiting for a thread to start loading segments on demand across threads.reportSegmentOnDemandLoadWaitTimeMax(long timeNs) Registers the maximum time spent loading segments on demand across all load threads.reportSegmentRows(long numRows) Reports the total number of rows in the processed segment.reportSegmentTime(long timeNs) Registers "segment time" metric.reportWaitTime(long timeNs) Registers "wait time" metric.voidvoidprotected voidsetDimension(String dimension, Object value) voidsqlQueryId(String sqlQueryId) Sets sqlQueryId as a dimensionvoidsqlQueryId(QueryType query) SetsQuery.getSqlQueryId()of the given query as dimensionvoidvoidstatusCode(int code) Sets the query status code SeeDruidMetrics.computeStatusCode(java.lang.Throwable).voidsubQueryId(QueryType query) SetsQuery.getSubQueryId()of the given query as dimension.voidsuccess(boolean success) voidvectorized(boolean vectorized) Sets whether or not a segment scan has been vectorized.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.query.QueryMetrics
filterBundle, postFilters, preFilters
-
Field Details
-
QUERY_TIME
- See Also:
-
QUERY_BYTES
- See Also:
-
QUERY_CPU_TIME
- See Also:
-
QUERY_WAIT_TIME
- See Also:
-
QUERY_SEGMENT_TIME
- See Also:
-
QUERY_SEGMENT_AND_CACHE_TIME
- See Also:
-
QUERY_RESULT_CACHE_HIT
- See Also:
-
QUERY_ON_DEMAND_LOAD_BATCH_TIME
- See Also:
-
QUERY_ON_DEMAND_LOAD_TIME_AVG
- See Also:
-
QUERY_ON_DEMAND_LOAD_TIME_MAX
- See Also:
-
QUERY_ON_DEMAND_WAIT_TIME_AVG
- See Also:
-
QUERY_ON_DEMAND_WAIT_TIME_MAX
- See Also:
-
QUERY_ON_DEMAND_LOAD_COUNT
- See Also:
-
QUERY_ON_DEMAND_LOAD_BYTES
- See Also:
-
builder
-
metrics
-
ownerThread
Non final to give subclasses ability to reassign it.
-
-
Constructor Details
-
DefaultQueryMetrics
public DefaultQueryMetrics()
-
-
Method Details
-
getTableNamesAsString
-
getIntervalsAsStringArray
-
checkModifiedFromOwnerThread
protected void checkModifiedFromOwnerThread() -
setDimension
-
query
Description copied from interface:QueryMetricsPulls all information from the query object into dimensions of future metrics.- Specified by:
queryin interfaceQueryMetrics<QueryType extends Query<?>>
-
dataSource
Description copied from interface:QueryMetricsSetsQuery.getDataSource()of the given query as dimension.- Specified by:
dataSourcein interfaceQueryMetrics<QueryType extends Query<?>>
-
queryType
Description copied from interface:QueryMetricsSetsQuery.getType()of the given query as dimension.- Specified by:
queryTypein interfaceQueryMetrics<QueryType extends Query<?>>
-
interval
Description copied from interface:QueryMetricsSetsQuery.getIntervals()of the given query as dimension.- Specified by:
intervalin interfaceQueryMetrics<QueryType extends Query<?>>
-
hasFilters
Description copied from interface:QueryMetricsSetsQuery.hasFilters()of the given query as dimension.- Specified by:
hasFiltersin interfaceQueryMetrics<QueryType extends Query<?>>
-
duration
Description copied from interface:QueryMetricsSetsQuery.getDuration()of the given query as dimension.- Specified by:
durationin interfaceQueryMetrics<QueryType extends Query<?>>
-
queryId
Description copied from interface:QueryMetricsSetsQuery.getId()of the given query as dimension.- Specified by:
queryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
queryId
Description copied from interface:QueryMetricsSets id of the given query as dimension.- Specified by:
queryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
subQueryId
Description copied from interface:QueryMetricsSetsQuery.getSubQueryId()of the given query as dimension.- Specified by:
subQueryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
sqlQueryId
Description copied from interface:QueryMetricsSetsQuery.getSqlQueryId()of the given query as dimension- Specified by:
sqlQueryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
sqlQueryId
Description copied from interface:QueryMetricsSets sqlQueryId as a dimension- Specified by:
sqlQueryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
context
Description copied from interface:QueryMetricsSetsQuery.getContext()of the given query as dimension.- Specified by:
contextin interfaceQueryMetrics<QueryType extends Query<?>>
-
server
- Specified by:
serverin interfaceQueryMetrics<QueryType extends Query<?>>
-
remoteAddress
- Specified by:
remoteAddressin interfaceQueryMetrics<QueryType extends Query<?>>
-
status
- Specified by:
statusin interfaceQueryMetrics<QueryType extends Query<?>>
-
success
public void success(boolean success) - Specified by:
successin interfaceQueryMetrics<QueryType extends Query<?>>
-
statusCode
public void statusCode(int code) Description copied from interface:QueryMetricsSets the query status code SeeDruidMetrics.computeStatusCode(java.lang.Throwable).- Specified by:
statusCodein interfaceQueryMetrics<QueryType extends Query<?>>
-
segment
- Specified by:
segmentin interfaceQueryMetrics<QueryType extends Query<?>>
-
projection
Description copied from interface:QueryMetricsIf a projection was used during segment processing, set its name as the projection dimension- Specified by:
projectionin interfaceQueryMetrics<QueryType extends Query<?>>
-
identity
Description copied from interface:QueryMetricsSets identity of the requester for a query. SeeAuthenticationResult.- Specified by:
identityin interfaceQueryMetrics<QueryType extends Query<?>>
-
vectorized
public void vectorized(boolean vectorized) Description copied from interface:QueryMetricsSets whether or not a segment scan has been vectorized. Generally expected to only be attached to segment-level metrics, since at whole-query level we might have a mix of vectorized and non-vectorized segment scans.- Specified by:
vectorizedin interfaceQueryMetrics<QueryType extends Query<?>>
-
parallelMergeParallelism
public void parallelMergeParallelism(int parallelism) Description copied from interface:QueryMetricsSets broker merge parallelism, if parallel merges are enabled. This will only appear in broker level metrics. This value is identical to theQueryMetrics.reportParallelMergeParallelism(int)metric value, but optionally also available as a dimension.- Specified by:
parallelMergeParallelismin interfaceQueryMetrics<QueryType extends Query<?>>
-
makeBitmapResultFactory
Description copied from interface:QueryMetricsCreates aBitmapResultFactorywhich may record some information along bitmap construction fromQueryMetrics.filterBundle(FilterBundle.BundleInfo). The returned BitmapResultFactory may add some dimensions to this QueryMetrics from it'sBitmapResultFactory.toImmutableBitmap(Object)method. SeeBitmapResultFactoryJavadoc for more information.- Specified by:
makeBitmapResultFactoryin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportQueryTime
Description copied from interface:QueryMetricsRegisters "query time" metric. Measures the time between a Jetty thread starting to handle a query, and the response being fully written to the response output stream. Does not include time spent waiting in a queue before the query runs.- Specified by:
reportQueryTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportQueryBytes
Description copied from interface:QueryMetricsRegisters "query bytes" metric. Measures the total number of bytes written by the query server thread to the response output stream. Emitted once per query.- Specified by:
reportQueryBytesin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportWaitTime
Description copied from interface:QueryMetricsRegisters "wait time" metric. Measures the total time segment-processing runnables spent waiting for execution in the processing thread pool. Emitted once per segment.- Specified by:
reportWaitTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentTime
Description copied from interface:QueryMetricsRegisters "segment time" metric. Measures the total wall-clock time spent operating on segments in processing threads. Emitted once per segment.- Specified by:
reportSegmentTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentAndCacheTime
Description copied from interface:QueryMetricsRegisters "segmentAndCache time" metric. Measures the total wall-clock time spent in processing threads, either operating on segments or retrieving items from cache. Emitted once per segment.- Specified by:
reportSegmentAndCacheTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentOnDemandLoadTime
Description copied from interface:QueryMetricsRegisters the apparent time spent loading segments on demand, before queing up for processing. This measurement is wall-clock time to when the last segment is finished loading and ready for processing.Emitted once per query
- Specified by:
reportSegmentOnDemandLoadTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentOnDemandLoadTimeAvg
Description copied from interface:QueryMetricsRegisters the average time spent loading segments on demand across threads.Emitted once per query
- Specified by:
reportSegmentOnDemandLoadTimeAvgin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentOnDemandLoadWaitTimeMax
Description copied from interface:QueryMetricsRegisters the maximum time spent loading segments on demand across all load threads.Emitted once per query
- Specified by:
reportSegmentOnDemandLoadWaitTimeMaxin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentOnDemandLoadWaitTimeAvg
Description copied from interface:QueryMetricsRegisters the average time spent waiting for a thread to start loading segments on demand across threads.Emitted once per query
- Specified by:
reportSegmentOnDemandLoadWaitTimeAvgin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentOnDemandLoadTimeMax
Description copied from interface:QueryMetricsRegisters the maximum time spent waiting for a thread to start loading segments on demand across all load threads.Emitted once per query
- Specified by:
reportSegmentOnDemandLoadTimeMaxin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentOnDemandLoadBytes
Description copied from interface:QueryMetricsRegisters the total number of bytes added to the cache when loading segments on demand, summing the sizes loaded by individual segement load threads.Emitted once per query
- Specified by:
reportSegmentOnDemandLoadBytesin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentOnDemandLoadCount
Description copied from interface:QueryMetricsRegisters the total numer of segments loaded on demand.Emitted once per query
- Specified by:
reportSegmentOnDemandLoadCountin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportResultCachePoll
Description copied from interface:QueryMetricsEmits iff a given query polled the result-level cache and the success of that operation.- Specified by:
reportResultCachePollin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportCpuTime
Description copied from interface:QueryMetricsRegisters "cpu time" metric.- Specified by:
reportCpuTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportNodeTimeToFirstByte
Description copied from interface:QueryMetricsRegisters "time to first byte" metric.- Specified by:
reportNodeTimeToFirstBytein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportBackPressureTime
Description copied from interface:QueryMetricsRegisters "time that channel is unreadable (backpressure)" metric.- Specified by:
reportBackPressureTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportNodeTime
Description copied from interface:QueryMetricsRegisters "node time" metric.- Specified by:
reportNodeTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportNodeBytes
Description copied from interface:QueryMetricsRegisters "node bytes" metric.- Specified by:
reportNodeBytesin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportBitmapConstructionTime
Description copied from interface:QueryMetricsReports the time spent constructing bitmap fromQueryMetrics.filterBundle(FilterBundle.BundleInfo)of the query. Not reported, if there are no indexes.- Specified by:
reportBitmapConstructionTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportSegmentRows
Description copied from interface:QueryMetricsReports the total number of rows in the processed segment.- Specified by:
reportSegmentRowsin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportPreFilteredRows
Description copied from interface:QueryMetricsReports the number of rows to scan in the segment after applyingQueryMetrics.filterBundle(FilterBundle.BundleInfo). If the are no indexes, this metric is equal toQueryMetrics.reportSegmentRows(long).- Specified by:
reportPreFilteredRowsin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportParallelMergeParallelism
Description copied from interface:QueryMetricsReports number of parallel tasks the broker used to process the query during parallel merge. This value is identical to theQueryMetrics.parallelMergeParallelism(int)dimension value, but optionally also available as a metric.- Specified by:
reportParallelMergeParallelismin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportParallelMergeInputSequences
Description copied from interface:QueryMetricsReports total number of input sequences processed by the broker during parallel merge.- Specified by:
reportParallelMergeInputSequencesin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportParallelMergeInputRows
Description copied from interface:QueryMetricsReports total number of input rows processed by the broker during parallel merge.- Specified by:
reportParallelMergeInputRowsin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportParallelMergeOutputRows
Description copied from interface:QueryMetricsReports broker total number of output rows after merging and combining input sequences (should be less than or equal to the value supplied toQueryMetrics.reportParallelMergeInputRows(long).- Specified by:
reportParallelMergeOutputRowsin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportParallelMergeTaskCount
Description copied from interface:QueryMetricsReports broker total number of fork join pool tasks required to complete query- Specified by:
reportParallelMergeTaskCountin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportParallelMergeTotalCpuTime
Description copied from interface:QueryMetricsReports broker total CPU time in nanoseconds where fork join merge combine tasks were doing work- Specified by:
reportParallelMergeTotalCpuTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportParallelMergeTotalTime
Description copied from interface:QueryMetricsReports broker total "wall" time in nanoseconds from parallel merge start sequence creation to total consumption.- Specified by:
reportParallelMergeTotalTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportParallelMergeFastestPartitionTime
Description copied from interface:QueryMetricsReports broker "wall" time in nanoseconds for the fastest parallel merge sequence partition to be 'initialized', where 'initialized' is time to the first result batch is populated from data servers and merging can begin. Similar to query 'time to first byte' metrics, except is a composite of the whole group of data servers which are present in the merge partition, which all must supply an initial result batch before merging can actually begin.- Specified by:
reportParallelMergeFastestPartitionTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportParallelMergeSlowestPartitionTime
Description copied from interface:QueryMetricsReports broker "wall" time in nanoseconds for the slowest parallel merge sequence partition to be 'initialized', where 'initialized' is time to the first result batch is populated from data servers and merging can begin. Similar to query 'time to first byte' metrics, except is a composite of the whole group of data servers which are present in the merge partition, which all must supply an initial result batch before merging can actually begin.- Specified by:
reportParallelMergeSlowestPartitionTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportQueriedSegmentCount
Description copied from interface:QueryMetricsRegisters "segments queried count" metric.- Specified by:
reportQueriedSegmentCountin interfaceQueryMetrics<QueryType extends Query<?>>
-
emit
Description copied from interface:QueryMetricsEmits all metrics, registered since the lastemit()call on this QueryMetrics object.- Specified by:
emitin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportMetric
-