Skip to content

Comments

Add streaming dimension to query categorization metrics#551

Merged
ansjcy merged 3 commits intoopensearch-project:mainfrom
harshavamsi:streaming_dimension
Feb 20, 2026
Merged

Add streaming dimension to query categorization metrics#551
ansjcy merged 3 commits intoopensearch-project:mainfrom
harshavamsi:streaming_dimension

Conversation

@harshavamsi
Copy link
Contributor

@harshavamsi harshavamsi commented Feb 18, 2026

Description

This PR works on top of opensearch-project/OpenSearch#20530. We now pass down a streaming flag for a request into the search request context from OpenSearch. We can then read that flag while categorizing a query and then tag that request with streaming. Right now streaming only works for aggregations so updated the aggregations tag

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
@harshavamsi
Copy link
Contributor Author

@rishabhmaurya @bowenlan-amzn @ansjcy for review

userPrincipalContext,
null
);
record.setStreaming(searchRequestContext.isStreamingRequest());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this stream flag in top queries record? Or just metrics?

If you need it in top queries, you need to do more than this and set / get, you need to change the serialization, copy constructor, equals, hascode etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the time being we just need it in the metrics, we might want to analyze top queries later but that is not part of the plan right now

*/
public void incrementAggCounter(double value, Tags tags, Map<MetricType, Measurement> measurements) {
public void incrementAggCounter(double value, Tags tags, Map<MetricType, Measurement> measurements, boolean isStreaming) {
tags.addTag(IS_STREAMING_TAG, String.valueOf(isStreaming));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is_streaming tag is only added to incrementAggCounter, but NOT to incrementCounter (query type counter) or incrementSortCounter. If a streaming request has a query clause and a sort clause but no aggregation, no streaming tag will be emitted for those metrics.

Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is intentional. For the time being, only aggregation queries(specifically terms agg) will be streaming. At some point in the future we might support regular queries. We have logic in core where if there is no agg, then by default we do not choose the streaming path.

@ansjcy
Copy link
Member

ansjcy commented Feb 20, 2026

Looks like the test is failing with

»  fatal error in thread [opensearch[integTest-1][search][T#6]], exiting
»  java.lang.NoSuchMethodError: 'boolean org.opensearch.action.search.SearchRequestContext.isStreamingRequest()'
»  	at org.opensearch.plugin.insights.core.listener.QueryInsightsListener.constructSearchQueryRecord(QueryInsightsListener.java:394)
»  	at org.opensearch.plugin.insights.core.listener.QueryInsightsListener.onRequestEnd(QueryInsightsListener.java:259)
»  	at org.opensearch.action.search.SearchRequestOperationsListener$CompositeListener.onRequestEnd(SearchRequestOperationsListener.java:131)
»  	at org.opensearch.action.search.AbstractSearchAsyncAction.onRequestEnd(AbstractSearchAsyncAction.java:503)
»  	at org.opensearch.action.search.AbstractSearchAsyncAction.sendSearchResponse(AbstractSearchAsyncAction.java:798)
»  	at org.opensearch.action.search.ExpandSearchPhase.run(ExpandSearchPhase.java:132)
»  	at org.opensearch.action.search.SearchPhase.recordAndRun(SearchPhase.java:62)
»  	at org.opensearch.action.search.AbstractSearchAsyncAction.executePhase(AbstractSearchAsyncAction.java:514)
»  	at org.opensearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:481)
»  	at org.opensearch.action.search.FetchSearchPhase.moveToNextPhase(FetchSearchPhase.java:300)
»  	at org.opensearch.action.search.FetchSearchPhase.lambda$innerRun$0(FetchSearchPhase.java:138)
»  	at org.opensearch.action.search.FetchSearchPhase.innerRun(FetchSearchPhase.java:150)
»  	at org.opensearch.action.search.FetchSearchPhase$1.doRun(FetchSearchPhase.java:122)
»  	at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52)
»  	at org.opensearch.threadpool.TaskAwareRunnable.doRun(TaskAwareRunnable.java:78)
»  	at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52)
»  	at org.opensearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:59)
»  	at org.opensearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:977)
»  	at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52)
»  	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
»  	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
»  	at java.base/java.lang.Thread.run(Thread.java:1474)

Do we need to merge the core change before this PR?

@ansjcy ansjcy changed the title Add streaming dimension Add streaming dimension to query categorization metrics Feb 20, 2026
@ansjcy ansjcy merged commit 2dd3aba into opensearch-project:main Feb 20, 2026
25 of 36 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Feb 20, 2026
Signed-off-by: Harsha Vamsi Kalluri <harshavamsi096@gmail.com>
(cherry picked from commit 2dd3aba)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants