-
Notifications
You must be signed in to change notification settings - Fork 3.8k
granularity method in QueryMetrics. #4570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7ccb88b
granularity method in QueryMetrics.
akashdw 1cc6b69
QueryMetricsFactory classes for search and select queries.
akashdw daf5763
Empty implementation for Granularity() method.
akashdw f4d46ad
Review comment changes.
akashdw dd4bf96
Remove unused import.
akashdw 84c1493
empty query() method.
akashdw 65775e0
checkstyle fix.
akashdw 9204199
Merge branch 'master' into granularity_metrics
akashdw f82d58b
Import fix.
akashdw dbe611f
Merge branch 'master' into granularity_metrics
akashdw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ public void query(GroupByQuery query) | |
| numDimensions(query); | ||
| numMetrics(query); | ||
| numComplexMetrics(query); | ||
| granularity(query); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -58,4 +59,10 @@ public void numComplexMetrics(GroupByQuery query) | |
| int numComplexAggs = DruidMetrics.findNumComplexAggs(query.getAggregatorSpecs()); | ||
| setDimension("numComplexMetrics", String.valueOf(numComplexAggs)); | ||
| } | ||
|
|
||
| @Override | ||
| public void granularity(GroupByQuery query) | ||
| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment "Don't emit by default". Same in other places |
||
| //Don't emit by default | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
240 changes: 240 additions & 0 deletions
240
processing/src/main/java/io/druid/query/search/DefaultSearchQueryMetrics.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,240 @@ | ||
| /* | ||
| * Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. Metamarkets licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package io.druid.query.search; | ||
|
|
||
| import com.metamx.emitter.service.ServiceEmitter; | ||
| import io.druid.collections.bitmap.BitmapFactory; | ||
| import io.druid.java.util.common.ISE; | ||
| import io.druid.query.BitmapResultFactory; | ||
| import io.druid.query.Query; | ||
| import io.druid.query.QueryMetrics; | ||
| import io.druid.query.filter.Filter; | ||
| import org.joda.time.Interval; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * 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 in {@link QueryMetrics} | ||
| * javadoc. | ||
| */ | ||
| public class DefaultSearchQueryMetrics implements SearchQueryMetrics | ||
| { | ||
| private QueryMetrics<Query<?>> delegateQueryMetrics; | ||
|
|
||
|
|
||
| // queryMetrics.query(query) must already be called on the provided queryMetrics. | ||
| public DefaultSearchQueryMetrics(QueryMetrics<Query<?>> queryMetrics) | ||
| { | ||
| this.delegateQueryMetrics = queryMetrics; | ||
| } | ||
|
|
||
| @Override | ||
| public void query(SearchQuery query) | ||
| { | ||
| //delegateQueryMetrics.query(query) must already be called on the provided queryMetrics. | ||
| } | ||
|
|
||
| @Override | ||
| public void dataSource(SearchQuery query) | ||
| { | ||
| throw new ISE("Unsupported method in default query metrics implementation."); | ||
| } | ||
|
|
||
| @Override | ||
| public void queryType(SearchQuery query) | ||
| { | ||
| throw new ISE("Unsupported method in default query metrics implementation."); | ||
| } | ||
|
|
||
| @Override | ||
| public void interval(SearchQuery query) | ||
| { | ||
| throw new ISE("Unsupported method in default query metrics implementation."); | ||
| } | ||
|
|
||
| @Override | ||
| public void hasFilters(SearchQuery query) | ||
| { | ||
| throw new ISE("Unsupported method in default query metrics implementation."); | ||
| } | ||
|
|
||
| @Override | ||
| public void duration(SearchQuery query) | ||
| { | ||
| throw new ISE("Unsupported method in default query metrics implementation."); | ||
| } | ||
|
|
||
| @Override | ||
| public void queryId(SearchQuery query) | ||
| { | ||
| throw new ISE("Unsupported method in default query metrics implementation."); | ||
| } | ||
|
|
||
| @Override | ||
| public void granularity(SearchQuery query) | ||
| { | ||
| // Don't emit by default | ||
| } | ||
|
|
||
| @Override | ||
| public void context(SearchQuery query) | ||
| { | ||
| delegateQueryMetrics.context(query); | ||
| } | ||
|
|
||
| @Override | ||
| public void server(String host) | ||
| { | ||
| delegateQueryMetrics.server(host); | ||
| } | ||
|
|
||
| @Override | ||
| public void remoteAddress(String remoteAddress) | ||
| { | ||
| delegateQueryMetrics.remoteAddress(remoteAddress); | ||
| } | ||
|
|
||
| @Override | ||
| public void status(String status) | ||
| { | ||
| delegateQueryMetrics.status(status); | ||
| } | ||
|
|
||
| @Override | ||
| public void success(boolean success) | ||
| { | ||
| delegateQueryMetrics.success(success); | ||
| } | ||
|
|
||
| @Override | ||
| public void segment(String segmentIdentifier) | ||
| { | ||
| delegateQueryMetrics.segment(segmentIdentifier); | ||
| } | ||
|
|
||
| @Override | ||
| public void chunkInterval(Interval interval) | ||
| { | ||
| delegateQueryMetrics.chunkInterval(interval); | ||
| } | ||
|
|
||
| @Override | ||
| public void preFilters(List<Filter> preFilters) | ||
| { | ||
| delegateQueryMetrics.preFilters(preFilters); | ||
| } | ||
|
|
||
| @Override | ||
| public void postFilters(List<Filter> postFilters) | ||
| { | ||
| delegateQueryMetrics.postFilters(postFilters); | ||
| } | ||
|
|
||
| @Override | ||
| public BitmapResultFactory<?> makeBitmapResultFactory(BitmapFactory factory) | ||
| { | ||
| return delegateQueryMetrics.makeBitmapResultFactory(factory); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportQueryTime(long timeNs) | ||
| { | ||
| return delegateQueryMetrics.reportQueryTime(timeNs); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportQueryBytes(long byteCount) | ||
| { | ||
| return delegateQueryMetrics.reportQueryBytes(byteCount); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportWaitTime(long timeNs) | ||
| { | ||
| return delegateQueryMetrics.reportWaitTime(timeNs); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportSegmentTime(long timeNs) | ||
| { | ||
| return delegateQueryMetrics.reportSegmentTime(timeNs); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportSegmentAndCacheTime(long timeNs) | ||
| { | ||
| return delegateQueryMetrics.reportSegmentAndCacheTime(timeNs); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportIntervalChunkTime(long timeNs) | ||
| { | ||
| return delegateQueryMetrics.reportIntervalChunkTime(timeNs); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportCpuTime(long timeNs) | ||
| { | ||
| return delegateQueryMetrics.reportCpuTime(timeNs); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportNodeTimeToFirstByte(long timeNs) | ||
| { | ||
| return delegateQueryMetrics.reportNodeTimeToFirstByte(timeNs); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportNodeTime(long timeNs) | ||
| { | ||
| return delegateQueryMetrics.reportNodeTime(timeNs); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportNodeBytes(long byteCount) | ||
| { | ||
| return delegateQueryMetrics.reportNodeBytes(byteCount); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportBitmapConstructionTime(long timeNs) | ||
| { | ||
| return delegateQueryMetrics.reportBitmapConstructionTime(timeNs); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportSegmentRows(long numRows) | ||
| { | ||
| return delegateQueryMetrics.reportSegmentRows(numRows); | ||
| } | ||
|
|
||
| @Override | ||
| public QueryMetrics reportPreFilteredRows(long numRows) | ||
| { | ||
| return delegateQueryMetrics.reportPreFilteredRows(numRows); | ||
| } | ||
|
|
||
| @Override | ||
| public void emit(ServiceEmitter emitter) | ||
| { | ||
| delegateQueryMetrics.emit(emitter); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
processing/src/main/java/io/druid/query/search/DefaultSearchQueryMetricsFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. Metamarkets licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package io.druid.query.search; | ||
|
|
||
| import com.google.common.annotations.VisibleForTesting; | ||
| import com.google.inject.Inject; | ||
| import io.druid.query.DefaultGenericQueryMetricsFactory; | ||
| import io.druid.query.GenericQueryMetricsFactory; | ||
|
|
||
| public class DefaultSearchQueryMetricsFactory implements SearchQueryMetricsFactory | ||
| { | ||
| private static final SearchQueryMetricsFactory INSTANCE = | ||
| new DefaultSearchQueryMetricsFactory(DefaultGenericQueryMetricsFactory.instance()); | ||
| private final GenericQueryMetricsFactory genericQueryMetricsFactory; | ||
|
|
||
| @Inject | ||
| public DefaultSearchQueryMetricsFactory(GenericQueryMetricsFactory genericQueryMetricsFactory) | ||
| { | ||
| this.genericQueryMetricsFactory = genericQueryMetricsFactory; | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| public static SearchQueryMetricsFactory instance() | ||
| { | ||
| return INSTANCE; | ||
| } | ||
|
|
||
| @Override | ||
| public SearchQueryMetrics makeMetrics(SearchQuery query) | ||
| { | ||
| return new DefaultSearchQueryMetrics(genericQueryMetricsFactory.makeMetrics(query)); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of referencing TopN, GroupBy and Timeseries as something that should not be taken as examples of following this procedure, in the end of the description of this procedure, please reference Search and Select as examples of this procedure implemented. Also please add notes about empty or exception throwing of
query()and other "pre-query-execution-time" methods to this procedure.