Package org.apache.druid.query.search
Class DefaultSearchQueryMetrics
- java.lang.Object
-
- org.apache.druid.query.search.DefaultSearchQueryMetrics
-
- All Implemented Interfaces:
QueryMetrics<SearchQuery>
,SearchQueryMetrics
public class DefaultSearchQueryMetrics extends Object implements SearchQueryMetrics
This class is implemented with delegation to another QueryMetrics for compatibility, see "Making subinterfaces of QueryMetrics for emitting custom dimensions and/or metrics for specific query types" section inQueryMetrics
javadoc.
-
-
Constructor Summary
Constructors Constructor Description DefaultSearchQueryMetrics(QueryMetrics<Query<?>> queryMetrics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
context(SearchQuery query)
SetsQuery.getContext()
of the given query as dimension.void
dataSource(SearchQuery query)
SetsQuery.getDataSource()
of the given query as dimension.void
duration(SearchQuery query)
SetsQuery.getDuration()
of the given query as dimension.void
emit(ServiceEmitter emitter)
Emits all metrics, registered since the lastemit()
call on this QueryMetrics object.void
granularity(SearchQuery query)
Sets the granularity ofBaseQuery.getGranularity()
of the given query as dimension.void
hasFilters(SearchQuery query)
SetsQuery.hasFilters()
of the given query as dimension.void
identity(String identity)
Sets identity of the requester for a query.void
interval(SearchQuery query)
SetsQuery.getIntervals()
of the given query as dimension.BitmapResultFactory<?>
makeBitmapResultFactory(BitmapFactory factory)
Creates aBitmapResultFactory
which may record some information along bitmap construction fromQueryMetrics.preFilters(List)
.void
parallelMergeParallelism(int parallelism)
Sets broker merge parallelism, if parallel merges are enabled.void
postFilters(List<Filter> postFilters)
void
preFilters(List<Filter> preFilters)
void
query(SearchQuery query)
Pulls all information from the query object into dimensions of future metrics.void
queryId(String queryId)
Sets id of the given query as dimension.void
queryId(SearchQuery query)
SetsQuery.getId()
of the given query as dimension.void
queryType(SearchQuery query)
SetsQuery.getType()
of the given query as dimension.void
remoteAddress(String remoteAddress)
QueryMetrics
reportBackPressureTime(long timeNs)
Registers "time that channel is unreadable (backpressure)" metric.QueryMetrics
reportBitmapConstructionTime(long timeNs)
Reports the time spent constructing bitmap fromQueryMetrics.preFilters(List)
of the query.QueryMetrics
reportCpuTime(long timeNs)
Registers "cpu time" metric.QueryMetrics
reportNodeBytes(long byteCount)
Registers "node bytes" metric.QueryMetrics
reportNodeTime(long timeNs)
Registers "node time" metric.QueryMetrics
reportNodeTimeToFirstByte(long timeNs)
Registers "time to first byte" metric.QueryMetrics
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
reportParallelMergeInputRows(long numRows)
Reports total number of input rows processed by the broker during parallel merge.QueryMetrics
reportParallelMergeInputSequences(long numSequences)
Reports total number of input sequences processed by the broker during parallel merge.QueryMetrics
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
reportParallelMergeParallelism(int parallelism)
Reports number of parallel tasks the broker used to process the query during parallel merge.QueryMetrics
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
reportParallelMergeTaskCount(long numTasks)
Reports broker total number of fork join pool tasks required to complete queryQueryMetrics
reportParallelMergeTotalCpuTime(long timeNs)
Reports broker total CPU time in nanoseconds where fork join merge combine tasks were doing workQueryMetrics
reportParallelMergeTotalTime(long timeNs)
Reports broker total "wall" time in nanoseconds from parallel merge start sequence creation to total consumption.QueryMetrics
reportPreFilteredRows(long numRows)
Reports the number of rows to scan in the segment after applyingQueryMetrics.preFilters(List)
.QueryMetrics
reportQueriedSegmentCount(long segmentCount)
Registers "segments queried count" metric.QueryMetrics
reportQueryBytes(long byteCount)
Registers "query bytes" metric.QueryMetrics
reportQueryTime(long timeNs)
Registers "query time" metric.QueryMetrics
reportSegmentAndCacheTime(long timeNs)
Registers "segmentAndCache time" metric.QueryMetrics
reportSegmentRows(long numRows)
Reports the total number of rows in the processed segment.QueryMetrics
reportSegmentTime(long timeNs)
Registers "segment time" metric.QueryMetrics
reportWaitTime(long timeNs)
Registers "wait time" metric.void
segment(String segmentIdentifier)
void
server(String host)
void
sqlQueryId(String sqlQueryId)
Sets sqlQueryId as a dimensionvoid
sqlQueryId(SearchQuery query)
SetsQuery.getSqlQueryId()
of the given query as dimensionvoid
status(String status)
void
subQueryId(SearchQuery query)
SetsQuery.getSubQueryId()
of the given query as dimension.void
success(boolean success)
void
vectorized(boolean vectorized)
Sets whether or not a segment scan has been vectorized.
-
-
-
Constructor Detail
-
DefaultSearchQueryMetrics
public DefaultSearchQueryMetrics(QueryMetrics<Query<?>> queryMetrics)
-
-
Method Detail
-
query
public void query(SearchQuery query)
Description copied from interface:QueryMetrics
Pulls all information from the query object into dimensions of future metrics.- Specified by:
query
in interfaceQueryMetrics<SearchQuery>
-
dataSource
public void dataSource(SearchQuery query)
Description copied from interface:QueryMetrics
SetsQuery.getDataSource()
of the given query as dimension.- Specified by:
dataSource
in interfaceQueryMetrics<SearchQuery>
-
queryType
public void queryType(SearchQuery query)
Description copied from interface:QueryMetrics
SetsQuery.getType()
of the given query as dimension.- Specified by:
queryType
in interfaceQueryMetrics<SearchQuery>
-
interval
public void interval(SearchQuery query)
Description copied from interface:QueryMetrics
SetsQuery.getIntervals()
of the given query as dimension.- Specified by:
interval
in interfaceQueryMetrics<SearchQuery>
-
hasFilters
public void hasFilters(SearchQuery query)
Description copied from interface:QueryMetrics
SetsQuery.hasFilters()
of the given query as dimension.- Specified by:
hasFilters
in interfaceQueryMetrics<SearchQuery>
-
duration
public void duration(SearchQuery query)
Description copied from interface:QueryMetrics
SetsQuery.getDuration()
of the given query as dimension.- Specified by:
duration
in interfaceQueryMetrics<SearchQuery>
-
queryId
public void queryId(SearchQuery query)
Description copied from interface:QueryMetrics
SetsQuery.getId()
of the given query as dimension.- Specified by:
queryId
in interfaceQueryMetrics<SearchQuery>
-
queryId
public void queryId(String queryId)
Description copied from interface:QueryMetrics
Sets id of the given query as dimension.- Specified by:
queryId
in interfaceQueryMetrics<SearchQuery>
-
subQueryId
public void subQueryId(SearchQuery query)
Description copied from interface:QueryMetrics
SetsQuery.getSubQueryId()
of the given query as dimension.- Specified by:
subQueryId
in interfaceQueryMetrics<SearchQuery>
-
sqlQueryId
public void sqlQueryId(SearchQuery query)
Description copied from interface:QueryMetrics
SetsQuery.getSqlQueryId()
of the given query as dimension- Specified by:
sqlQueryId
in interfaceQueryMetrics<SearchQuery>
-
sqlQueryId
public void sqlQueryId(String sqlQueryId)
Description copied from interface:QueryMetrics
Sets sqlQueryId as a dimension- Specified by:
sqlQueryId
in interfaceQueryMetrics<SearchQuery>
-
granularity
public void granularity(SearchQuery query)
Description copied from interface:SearchQueryMetrics
Sets the granularity ofBaseQuery.getGranularity()
of the given query as dimension. This method is going to be used in "full" metrics impl, see https://github.com/apache/druid/pull/4570#issuecomment-319458229- Specified by:
granularity
in interfaceSearchQueryMetrics
-
context
public void context(SearchQuery query)
Description copied from interface:QueryMetrics
SetsQuery.getContext()
of the given query as dimension.- Specified by:
context
in interfaceQueryMetrics<SearchQuery>
-
server
public void server(String host)
- Specified by:
server
in interfaceQueryMetrics<SearchQuery>
-
remoteAddress
public void remoteAddress(String remoteAddress)
- Specified by:
remoteAddress
in interfaceQueryMetrics<SearchQuery>
-
status
public void status(String status)
- Specified by:
status
in interfaceQueryMetrics<SearchQuery>
-
success
public void success(boolean success)
- Specified by:
success
in interfaceQueryMetrics<SearchQuery>
-
segment
public void segment(String segmentIdentifier)
- Specified by:
segment
in interfaceQueryMetrics<SearchQuery>
-
preFilters
public void preFilters(List<Filter> preFilters)
- Specified by:
preFilters
in interfaceQueryMetrics<SearchQuery>
-
postFilters
public void postFilters(List<Filter> postFilters)
- Specified by:
postFilters
in interfaceQueryMetrics<SearchQuery>
-
identity
public void identity(String identity)
Description copied from interface:QueryMetrics
Sets identity of the requester for a query. SeeAuthenticationResult
.- Specified by:
identity
in interfaceQueryMetrics<SearchQuery>
-
vectorized
public void vectorized(boolean vectorized)
Description copied from interface:QueryMetrics
Sets 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:
vectorized
in interfaceQueryMetrics<SearchQuery>
-
parallelMergeParallelism
public void parallelMergeParallelism(int parallelism)
Description copied from interface:QueryMetrics
Sets 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:
parallelMergeParallelism
in interfaceQueryMetrics<SearchQuery>
-
makeBitmapResultFactory
public BitmapResultFactory<?> makeBitmapResultFactory(BitmapFactory factory)
Description copied from interface:QueryMetrics
Creates aBitmapResultFactory
which may record some information along bitmap construction fromQueryMetrics.preFilters(List)
. The returned BitmapResultFactory may add some dimensions to this QueryMetrics from it'sBitmapResultFactory.toImmutableBitmap(Object)
method. SeeBitmapResultFactory
Javadoc for more information.- Specified by:
makeBitmapResultFactory
in interfaceQueryMetrics<SearchQuery>
-
reportQueryTime
public QueryMetrics reportQueryTime(long timeNs)
Description copied from interface:QueryMetrics
Registers "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:
reportQueryTime
in interfaceQueryMetrics<SearchQuery>
-
reportQueryBytes
public QueryMetrics reportQueryBytes(long byteCount)
Description copied from interface:QueryMetrics
Registers "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:
reportQueryBytes
in interfaceQueryMetrics<SearchQuery>
-
reportWaitTime
public QueryMetrics reportWaitTime(long timeNs)
Description copied from interface:QueryMetrics
Registers "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:
reportWaitTime
in interfaceQueryMetrics<SearchQuery>
-
reportSegmentTime
public QueryMetrics reportSegmentTime(long timeNs)
Description copied from interface:QueryMetrics
Registers "segment time" metric. Measures the total wall-clock time spent operating on segments in processing threads. Emitted once per segment.- Specified by:
reportSegmentTime
in interfaceQueryMetrics<SearchQuery>
-
reportSegmentAndCacheTime
public QueryMetrics reportSegmentAndCacheTime(long timeNs)
Description copied from interface:QueryMetrics
Registers "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:
reportSegmentAndCacheTime
in interfaceQueryMetrics<SearchQuery>
-
reportCpuTime
public QueryMetrics reportCpuTime(long timeNs)
Description copied from interface:QueryMetrics
Registers "cpu time" metric.- Specified by:
reportCpuTime
in interfaceQueryMetrics<SearchQuery>
-
reportNodeTimeToFirstByte
public QueryMetrics reportNodeTimeToFirstByte(long timeNs)
Description copied from interface:QueryMetrics
Registers "time to first byte" metric.- Specified by:
reportNodeTimeToFirstByte
in interfaceQueryMetrics<SearchQuery>
-
reportBackPressureTime
public QueryMetrics reportBackPressureTime(long timeNs)
Description copied from interface:QueryMetrics
Registers "time that channel is unreadable (backpressure)" metric.- Specified by:
reportBackPressureTime
in interfaceQueryMetrics<SearchQuery>
-
reportNodeTime
public QueryMetrics reportNodeTime(long timeNs)
Description copied from interface:QueryMetrics
Registers "node time" metric.- Specified by:
reportNodeTime
in interfaceQueryMetrics<SearchQuery>
-
reportNodeBytes
public QueryMetrics reportNodeBytes(long byteCount)
Description copied from interface:QueryMetrics
Registers "node bytes" metric.- Specified by:
reportNodeBytes
in interfaceQueryMetrics<SearchQuery>
-
reportBitmapConstructionTime
public QueryMetrics reportBitmapConstructionTime(long timeNs)
Description copied from interface:QueryMetrics
Reports the time spent constructing bitmap fromQueryMetrics.preFilters(List)
of the query. Not reported, if there are no preFilters.- Specified by:
reportBitmapConstructionTime
in interfaceQueryMetrics<SearchQuery>
-
reportSegmentRows
public QueryMetrics reportSegmentRows(long numRows)
Description copied from interface:QueryMetrics
Reports the total number of rows in the processed segment.- Specified by:
reportSegmentRows
in interfaceQueryMetrics<SearchQuery>
-
reportPreFilteredRows
public QueryMetrics reportPreFilteredRows(long numRows)
Description copied from interface:QueryMetrics
Reports the number of rows to scan in the segment after applyingQueryMetrics.preFilters(List)
. If the are no preFilters, this metric is equal toQueryMetrics.reportSegmentRows(long)
.- Specified by:
reportPreFilteredRows
in interfaceQueryMetrics<SearchQuery>
-
reportParallelMergeParallelism
public QueryMetrics reportParallelMergeParallelism(int parallelism)
Description copied from interface:QueryMetrics
Reports 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:
reportParallelMergeParallelism
in interfaceQueryMetrics<SearchQuery>
-
reportParallelMergeInputSequences
public QueryMetrics reportParallelMergeInputSequences(long numSequences)
Description copied from interface:QueryMetrics
Reports total number of input sequences processed by the broker during parallel merge.- Specified by:
reportParallelMergeInputSequences
in interfaceQueryMetrics<SearchQuery>
-
reportParallelMergeInputRows
public QueryMetrics reportParallelMergeInputRows(long numRows)
Description copied from interface:QueryMetrics
Reports total number of input rows processed by the broker during parallel merge.- Specified by:
reportParallelMergeInputRows
in interfaceQueryMetrics<SearchQuery>
-
reportParallelMergeOutputRows
public QueryMetrics reportParallelMergeOutputRows(long numRows)
Description copied from interface:QueryMetrics
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)
.- Specified by:
reportParallelMergeOutputRows
in interfaceQueryMetrics<SearchQuery>
-
reportParallelMergeTaskCount
public QueryMetrics reportParallelMergeTaskCount(long numTasks)
Description copied from interface:QueryMetrics
Reports broker total number of fork join pool tasks required to complete query- Specified by:
reportParallelMergeTaskCount
in interfaceQueryMetrics<SearchQuery>
-
reportParallelMergeTotalCpuTime
public QueryMetrics reportParallelMergeTotalCpuTime(long timeNs)
Description copied from interface:QueryMetrics
Reports broker total CPU time in nanoseconds where fork join merge combine tasks were doing work- Specified by:
reportParallelMergeTotalCpuTime
in interfaceQueryMetrics<SearchQuery>
-
reportParallelMergeTotalTime
public QueryMetrics reportParallelMergeTotalTime(long timeNs)
Description copied from interface:QueryMetrics
Reports broker total "wall" time in nanoseconds from parallel merge start sequence creation to total consumption.- Specified by:
reportParallelMergeTotalTime
in interfaceQueryMetrics<SearchQuery>
-
reportParallelMergeFastestPartitionTime
public QueryMetrics reportParallelMergeFastestPartitionTime(long timeNs)
Description copied from interface:QueryMetrics
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. 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:
reportParallelMergeFastestPartitionTime
in interfaceQueryMetrics<SearchQuery>
-
reportParallelMergeSlowestPartitionTime
public QueryMetrics reportParallelMergeSlowestPartitionTime(long timeNs)
Description copied from interface:QueryMetrics
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. 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:
reportParallelMergeSlowestPartitionTime
in interfaceQueryMetrics<SearchQuery>
-
reportQueriedSegmentCount
public QueryMetrics reportQueriedSegmentCount(long segmentCount)
Description copied from interface:QueryMetrics
Registers "segments queried count" metric.- Specified by:
reportQueriedSegmentCount
in interfaceQueryMetrics<SearchQuery>
-
emit
public void emit(ServiceEmitter emitter)
Description copied from interface:QueryMetrics
Emits all metrics, registered since the lastemit()
call on this QueryMetrics object.- Specified by:
emit
in interfaceQueryMetrics<SearchQuery>
-
-