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 anotherownerThreadfield should be updated.
-
-
Field Summary
Fields Modifier and Type Field Description protected ServiceMetricEvent.Builderbuilderprotected Map<String,Number>metricsprotected ThreadownerThreadNon final to give subclasses ability to reassign it.static StringQUERY_SEGMENT_AND_CACHE_TIMEstatic StringQUERY_SEGMENT_TIMEstatic StringQUERY_WAIT_TIME
-
Constructor Summary
Constructors Constructor Description DefaultQueryMetrics()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckModifiedFromOwnerThread()voidcontext(QueryType query)SetsQuery.getContext()of the given query as dimension.voiddataSource(QueryType query)SetsQuery.getDataSource()of the given query as dimension.voidduration(QueryType query)SetsQuery.getDuration()of the given query as dimension.voidemit(ServiceEmitter emitter)Emits all metrics, registered since the lastemit()call on this QueryMetrics object.voidhasFilters(QueryType query)SetsQuery.hasFilters()of the given query as dimension.voididentity(String identity)Sets identity of the requester for a query.voidinterval(QueryType query)SetsQuery.getIntervals()of the given query as dimension.BitmapResultFactory<?>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 dimensionvoidquery(QueryType query)Pulls all information from the query object into dimensions of future metrics.voidqueryId(String queryId)Sets id of the given query as dimension.voidqueryId(QueryType query)SetsQuery.getId()of the given query as dimension.voidqueryType(QueryType query)SetsQuery.getType()of the given query as dimension.voidremoteAddress(String remoteAddress)QueryMetrics<QueryType>reportBackPressureTime(long timeNs)Registers "time that channel is unreadable (backpressure)" metric.QueryMetrics<QueryType>reportBitmapConstructionTime(long timeNs)Reports the time spent constructing bitmap fromQueryMetrics.filterBundle(FilterBundle.BundleInfo)of the query.QueryMetrics<QueryType>reportCpuTime(long timeNs)Registers "cpu time" metric.protected QueryMetrics<QueryType>reportMetric(String metricName, Number value)QueryMetrics<QueryType>reportNodeBytes(long byteCount)Registers "node bytes" metric.QueryMetrics<QueryType>reportNodeTime(long timeNs)Registers "node time" metric.QueryMetrics<QueryType>reportNodeTimeToFirstByte(long timeNs)Registers "time to first byte" metric.QueryMetrics<QueryType>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.QueryMetrics<QueryType>reportParallelMergeInputRows(long numRows)Reports total number of input rows processed by the broker during parallel merge.QueryMetrics<QueryType>reportParallelMergeInputSequences(long numSequences)Reports total number of input sequences processed by the broker during parallel merge.QueryMetrics<QueryType>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).QueryMetrics<QueryType>reportParallelMergeParallelism(int parallelism)Reports number of parallel tasks the broker used to process the query during parallel merge.QueryMetrics<QueryType>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.QueryMetrics<QueryType>reportParallelMergeTaskCount(long numTasks)Reports broker total number of fork join pool tasks required to complete queryQueryMetrics<QueryType>reportParallelMergeTotalCpuTime(long timeNs)Reports broker total CPU time in nanoseconds where fork join merge combine tasks were doing workQueryMetrics<QueryType>reportParallelMergeTotalTime(long timeNs)Reports broker total "wall" time in nanoseconds from parallel merge start sequence creation to total consumption.QueryMetrics<QueryType>reportPreFilteredRows(long numRows)Reports the number of rows to scan in the segment after applyingQueryMetrics.filterBundle(FilterBundle.BundleInfo).QueryMetrics<QueryType>reportQueriedSegmentCount(long segmentCount)Registers "segments queried count" metric.QueryMetrics<QueryType>reportQueryBytes(long byteCount)Registers "query bytes" metric.QueryMetrics<QueryType>reportQueryTime(long timeNs)Registers "query time" metric.QueryMetrics<QueryType>reportSegmentAndCacheTime(long timeNs)Registers "segmentAndCache time" metric.QueryMetrics<QueryType>reportSegmentRows(long numRows)Reports the total number of rows in the processed segment.QueryMetrics<QueryType>reportSegmentTime(long timeNs)Registers "segment time" metric.QueryMetrics<QueryType>reportWaitTime(long timeNs)Registers "wait time" metric.voidsegment(String segmentIdentifier)voidserver(String host)protected voidsetDimension(String dimension, Object value)voidsqlQueryId(String sqlQueryId)Sets sqlQueryId as a dimensionvoidsqlQueryId(QueryType query)SetsQuery.getSqlQueryId()of the given query as dimensionvoidstatus(String status)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, wait
-
Methods inherited from interface org.apache.druid.query.QueryMetrics
filterBundle, postFilters, preFilters
-
-
-
-
Field Detail
-
QUERY_WAIT_TIME
public static final String QUERY_WAIT_TIME
- See Also:
- Constant Field Values
-
QUERY_SEGMENT_TIME
public static final String QUERY_SEGMENT_TIME
- See Also:
- Constant Field Values
-
QUERY_SEGMENT_AND_CACHE_TIME
public static final String QUERY_SEGMENT_AND_CACHE_TIME
- See Also:
- Constant Field Values
-
builder
protected final ServiceMetricEvent.Builder builder
-
ownerThread
protected Thread ownerThread
Non final to give subclasses ability to reassign it.
-
-
Method Detail
-
checkModifiedFromOwnerThread
protected void checkModifiedFromOwnerThread()
-
query
public void query(QueryType 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
public void dataSource(QueryType query)
Description copied from interface:QueryMetricsSetsQuery.getDataSource()of the given query as dimension.- Specified by:
dataSourcein interfaceQueryMetrics<QueryType extends Query<?>>
-
queryType
public void queryType(QueryType query)
Description copied from interface:QueryMetricsSetsQuery.getType()of the given query as dimension.- Specified by:
queryTypein interfaceQueryMetrics<QueryType extends Query<?>>
-
interval
public void interval(QueryType query)
Description copied from interface:QueryMetricsSetsQuery.getIntervals()of the given query as dimension.- Specified by:
intervalin interfaceQueryMetrics<QueryType extends Query<?>>
-
hasFilters
public void hasFilters(QueryType query)
Description copied from interface:QueryMetricsSetsQuery.hasFilters()of the given query as dimension.- Specified by:
hasFiltersin interfaceQueryMetrics<QueryType extends Query<?>>
-
duration
public void duration(QueryType query)
Description copied from interface:QueryMetricsSetsQuery.getDuration()of the given query as dimension.- Specified by:
durationin interfaceQueryMetrics<QueryType extends Query<?>>
-
queryId
public void queryId(QueryType query)
Description copied from interface:QueryMetricsSetsQuery.getId()of the given query as dimension.- Specified by:
queryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
queryId
public void queryId(String queryId)
Description copied from interface:QueryMetricsSets id of the given query as dimension.- Specified by:
queryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
subQueryId
public void subQueryId(QueryType query)
Description copied from interface:QueryMetricsSetsQuery.getSubQueryId()of the given query as dimension.- Specified by:
subQueryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
sqlQueryId
public void sqlQueryId(QueryType query)
Description copied from interface:QueryMetricsSetsQuery.getSqlQueryId()of the given query as dimension- Specified by:
sqlQueryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
sqlQueryId
public void sqlQueryId(String sqlQueryId)
Description copied from interface:QueryMetricsSets sqlQueryId as a dimension- Specified by:
sqlQueryIdin interfaceQueryMetrics<QueryType extends Query<?>>
-
context
public void context(QueryType query)
Description copied from interface:QueryMetricsSetsQuery.getContext()of the given query as dimension.- Specified by:
contextin interfaceQueryMetrics<QueryType extends Query<?>>
-
server
public void server(String host)
- Specified by:
serverin interfaceQueryMetrics<QueryType extends Query<?>>
-
remoteAddress
public void remoteAddress(String remoteAddress)
- Specified by:
remoteAddressin interfaceQueryMetrics<QueryType extends Query<?>>
-
status
public void status(String status)
- Specified by:
statusin interfaceQueryMetrics<QueryType extends Query<?>>
-
success
public void success(boolean success)
- Specified by:
successin interfaceQueryMetrics<QueryType extends Query<?>>
-
segment
public void segment(String segmentIdentifier)
- Specified by:
segmentin interfaceQueryMetrics<QueryType extends Query<?>>
-
projection
public void projection(String 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
public void identity(String 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
public BitmapResultFactory<?> makeBitmapResultFactory(BitmapFactory factory)
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
public QueryMetrics<QueryType> reportQueryTime(long timeNs)
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
public QueryMetrics<QueryType> reportQueryBytes(long byteCount)
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
public QueryMetrics<QueryType> reportWaitTime(long timeNs)
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
public QueryMetrics<QueryType> reportSegmentTime(long timeNs)
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
public QueryMetrics<QueryType> reportSegmentAndCacheTime(long timeNs)
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<?>>
-
reportCpuTime
public QueryMetrics<QueryType> reportCpuTime(long timeNs)
Description copied from interface:QueryMetricsRegisters "cpu time" metric.- Specified by:
reportCpuTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportNodeTimeToFirstByte
public QueryMetrics<QueryType> reportNodeTimeToFirstByte(long timeNs)
Description copied from interface:QueryMetricsRegisters "time to first byte" metric.- Specified by:
reportNodeTimeToFirstBytein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportBackPressureTime
public QueryMetrics<QueryType> reportBackPressureTime(long timeNs)
Description copied from interface:QueryMetricsRegisters "time that channel is unreadable (backpressure)" metric.- Specified by:
reportBackPressureTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportNodeTime
public QueryMetrics<QueryType> reportNodeTime(long timeNs)
Description copied from interface:QueryMetricsRegisters "node time" metric.- Specified by:
reportNodeTimein interfaceQueryMetrics<QueryType extends Query<?>>
-
reportNodeBytes
public QueryMetrics<QueryType> reportNodeBytes(long byteCount)
Description copied from interface:QueryMetricsRegisters "node bytes" metric.- Specified by:
reportNodeBytesin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportBitmapConstructionTime
public QueryMetrics<QueryType> reportBitmapConstructionTime(long timeNs)
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
public QueryMetrics<QueryType> reportSegmentRows(long numRows)
Description copied from interface:QueryMetricsReports the total number of rows in the processed segment.- Specified by:
reportSegmentRowsin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportPreFilteredRows
public QueryMetrics<QueryType> reportPreFilteredRows(long numRows)
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
public QueryMetrics<QueryType> reportParallelMergeParallelism(int parallelism)
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
public QueryMetrics<QueryType> reportParallelMergeInputSequences(long numSequences)
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
public QueryMetrics<QueryType> reportParallelMergeInputRows(long numRows)
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
public QueryMetrics<QueryType> reportParallelMergeOutputRows(long numRows)
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
public QueryMetrics<QueryType> reportParallelMergeTaskCount(long numTasks)
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
public QueryMetrics<QueryType> reportParallelMergeTotalCpuTime(long timeNs)
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
public QueryMetrics<QueryType> reportParallelMergeTotalTime(long timeNs)
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
public QueryMetrics<QueryType> reportParallelMergeFastestPartitionTime(long timeNs)
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
public QueryMetrics<QueryType> reportParallelMergeSlowestPartitionTime(long timeNs)
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
public QueryMetrics<QueryType> reportQueriedSegmentCount(long segmentCount)
Description copied from interface:QueryMetricsRegisters "segments queried count" metric.- Specified by:
reportQueriedSegmentCountin interfaceQueryMetrics<QueryType extends Query<?>>
-
emit
public void emit(ServiceEmitter emitter)
Description copied from interface:QueryMetricsEmits all metrics, registered since the lastemit()call on this QueryMetrics object.- Specified by:
emitin interfaceQueryMetrics<QueryType extends Query<?>>
-
reportMetric
protected QueryMetrics<QueryType> reportMetric(String metricName, Number value)
-
-