Add search document count metric#580
Open
shivamg2017 wants to merge 1 commit intoopensearch-project:mainfrom
Open
Add search document count metric#580shivamg2017 wants to merge 1 commit intoopensearch-project:mainfrom
shivamg2017 wants to merge 1 commit intoopensearch-project:mainfrom
Conversation
Signed-off-by: shivamg2017 <shivamgupta.6july@gmail.com>
dzane17
reviewed
Apr 1, 2026
Member
dzane17
left a comment
There was a problem hiding this comment.
Can you add tests?
QueryInsightsListenerTests.testOnRequestEnd should mock searchRequestContext.getHitsLength() and assert the value on the captured record, similar to how isStreamingRequest() / isStreaming() is tested today.
SearchQueryCategorizerTests should verify that recordSearchDocCount is called with the expected value when categorize runs.
| * | ||
| * @param other the {@link SearchQueryRecord} to copy. | ||
| */ | ||
| public SearchQueryRecord(SearchQueryRecord other) { |
Member
There was a problem hiding this comment.
Please add hitsLength to the copy constructor. I know the value is only used for categorization histograms, but we should still keep this method up to date.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Add search document count metric
Metric to fetch doc count returned by search query.
Relevant Opensearch PR to update SearchRequestContext : opensearch-project/OpenSearch#21037
metric: ImmutableMetricData{resource=Resource{schemaUrl=null, attributes={service.name="OpenSearch"}}, instrumentationScopeInfo=InstrumentationScopeInfo{name=org.opensearch.telemetry, version=null, schemaUrl=null, attributes={}}, name=search.query.doc_count.histogram, description=Histogram for the number of documents returned per search query, unit=1, type=EXPONENTIAL_HISTOGRAM, data=ImmutableExponentialHistogramData{aggregationTemporality=CUMULATIVE, points=[ImmutableExponentialHistogramPointData{getStartEpochNanos=1774810013641740000, getEpochNanos=1774810493652552000, getAttributes={}, getScale=20, getSum=12.0, getCount=4, getZeroCount=0, hasMin=true, getMin=3.0, hasMax=true, getMax=3.0, getPositiveBuckets=DoubleExponentialHistogramBuckets{scale: 20, offset: 1661953, counts: {1661953=4} }, getNegativeBuckets=EmptyExponentialHistogramBuckets{scale=20, offset=0, bucketCounts=[], totalCount=0}, getExemplars=[]}]}}