-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into fix_alias
- Loading branch information
Showing
15 changed files
with
313 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 @@ | ||
f11560da189ab563a5c8e351941415430e9304ea |
55 changes: 55 additions & 0 deletions
55
server/src/main/java/org/opensearch/action/search/SearchQueryAggregationCategorizer.java
This file contains 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,55 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.search; | ||
|
||
import org.opensearch.search.aggregations.AggregationBuilder; | ||
import org.opensearch.search.aggregations.PipelineAggregationBuilder; | ||
import org.opensearch.telemetry.metrics.tags.Tags; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Increments the counters related to Aggregation Search Queries. | ||
*/ | ||
public class SearchQueryAggregationCategorizer { | ||
|
||
private static final String TYPE_TAG = "type"; | ||
private final SearchQueryCounters searchQueryCounters; | ||
|
||
public SearchQueryAggregationCategorizer(SearchQueryCounters searchQueryCounters) { | ||
this.searchQueryCounters = searchQueryCounters; | ||
} | ||
|
||
public void incrementSearchQueryAggregationCounters(Collection<AggregationBuilder> aggregatorFactories) { | ||
for (AggregationBuilder aggregationBuilder : aggregatorFactories) { | ||
incrementCountersRecursively(aggregationBuilder); | ||
} | ||
} | ||
|
||
private void incrementCountersRecursively(AggregationBuilder aggregationBuilder) { | ||
// Increment counters for the current aggregation | ||
String aggregationType = aggregationBuilder.getType(); | ||
searchQueryCounters.aggCounter.add(1, Tags.create().addTag(TYPE_TAG, aggregationType)); | ||
|
||
// Recursively process sub-aggregations if any | ||
Collection<AggregationBuilder> subAggregations = aggregationBuilder.getSubAggregations(); | ||
if (subAggregations != null && !subAggregations.isEmpty()) { | ||
for (AggregationBuilder subAggregation : subAggregations) { | ||
incrementCountersRecursively(subAggregation); | ||
} | ||
Check warning on line 45 in server/src/main/java/org/opensearch/action/search/SearchQueryAggregationCategorizer.java Codecov / codecov/patchserver/src/main/java/org/opensearch/action/search/SearchQueryAggregationCategorizer.java#L44-L45
|
||
} | ||
|
||
// Process pipeline aggregations | ||
Collection<PipelineAggregationBuilder> pipelineAggregations = aggregationBuilder.getPipelineAggregations(); | ||
for (PipelineAggregationBuilder pipelineAggregation : pipelineAggregations) { | ||
String pipelineAggregationType = pipelineAggregation.getType(); | ||
searchQueryCounters.aggCounter.add(1, Tags.create().addTag(TYPE_TAG, pipelineAggregationType)); | ||
} | ||
Check warning on line 53 in server/src/main/java/org/opensearch/action/search/SearchQueryAggregationCategorizer.java Codecov / codecov/patchserver/src/main/java/org/opensearch/action/search/SearchQueryAggregationCategorizer.java#L51-L53
|
||
} | ||
} |
This file contains 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 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
Oops, something went wrong.