Skip to content

Refactor HttpStats, ScriptStats, AdaptiveSelectionStats and OsStats with Builder pattern#20014

Merged
sandeshkr419 merged 7 commits intoopensearch-project:mainfrom
pado0:builder-http-script-adaptive-os
Nov 19, 2025
Merged

Refactor HttpStats, ScriptStats, AdaptiveSelectionStats and OsStats with Builder pattern#20014
sandeshkr419 merged 7 commits intoopensearch-project:mainfrom
pado0:builder-http-script-adaptive-os

Conversation

@pado0
Copy link
Copy Markdown
Contributor

@pado0 pado0 commented Nov 16, 2025

Description

This PR refactors the HttpStats, ScriptStats, AdaptiveSelectionStats and OsStats class to use the Builder pattern instead of relying on multiple constructors.

By adopting the Builder pattern, it becomes easier to evolve the stats API, add new metrics, and maintain backward compatibility without forcing disruptive constructor changes.

Based on the related issue:

  1. Added a Builder and deprecated the existing constructors.
  2. Replaced usages of constructors in code and tests with the new Builder.

There are multiple stats-related classes that need similar refactoring, and we are addressing them in priority order. This PR covers HttpStats, ScriptStats, AdaptiveSelectionStats and OsStats as part of that effort.

Related Issues

Related to #19225

Check List

  • Functionality includes testing.

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.

@pado0 pado0 force-pushed the builder-http-script-adaptive-os branch from 9ac29eb to 288f05b Compare November 16, 2025 08:24
@pado0 pado0 marked this pull request as ready for review November 16, 2025 08:45
@pado0 pado0 requested a review from a team as a code owner November 16, 2025 08:45
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 288f05b: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Copy Markdown
Contributor

✅ Gradle check result for 288f05b: SUCCESS

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 16, 2025

Codecov Report

❌ Patch coverage is 86.13861% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.16%. Comparing base (ab4bd69) to head (736ac80).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...c/main/java/org/opensearch/script/ScriptStats.java 85.36% 6 Missing ⚠️
...n/java/org/opensearch/script/ScriptCacheStats.java 0.00% 4 Missing ⚠️
.../org/opensearch/node/ResponseCollectorService.java 0.00% 3 Missing ⚠️
...g/opensearch/http/AbstractHttpServerTransport.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               main   #20014    +/-   ##
==========================================
  Coverage     73.15%   73.16%            
- Complexity    71455    71524    +69     
==========================================
  Files          5789     5789            
  Lines        327128   327259   +131     
  Branches      47122    47126     +4     
==========================================
+ Hits         239326   239451   +125     
- Misses        68594    68625    +31     
+ Partials      19208    19183    -25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@sandeshkr419 sandeshkr419 left a comment

Choose a reason for hiding this comment

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

Minor comments, rest LGTM!

Thanks for working on this! :D

Copy link
Copy Markdown
Member

@sandeshkr419 sandeshkr419 left a comment

Choose a reason for hiding this comment

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

one small nit-pick, rest LGTM!

Signed-off-by: Jean Kim <bgshhd95@gmail.com>
Signed-off-by: Jean Kim <bgshhd95@gmail.com>
Signed-off-by: Jean Kim <bgshhd95@gmail.com>
Signed-off-by: Jean Kim <bgshhd95@gmail.com>
Signed-off-by: Jean Kim <bgshhd95@gmail.com>
Signed-off-by: Jean Kim <bgshhd95@gmail.com>
@pado0 pado0 force-pushed the builder-http-script-adaptive-os branch from 748d555 to 566e103 Compare November 18, 2025 21:56
@github-actions github-actions bot added enhancement Enhancement or improvement to existing feature or request good first issue Good for newcomers Indexing Indexing, Bulk Indexing and anything related to indexing Other Search Search query, autocomplete ...etc labels Nov 18, 2025
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 566e103: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 566e103: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
@sandeshkr419 sandeshkr419 removed good first issue Good for newcomers Indexing Indexing, Bulk Indexing and anything related to indexing Search Search query, autocomplete ...etc labels Nov 19, 2025
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 736ac80: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@pado0 pado0 closed this Nov 19, 2025
@pado0 pado0 reopened this Nov 19, 2025
@github-actions github-actions bot added good first issue Good for newcomers Indexing Indexing, Bulk Indexing and anything related to indexing Search Search query, autocomplete ...etc labels Nov 19, 2025
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 736ac80: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@pado0 pado0 closed this Nov 19, 2025
@pado0 pado0 reopened this Nov 19, 2025
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 736ac80: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Copy Markdown
Contributor

❕ Gradle check result for 736ac80: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@sandeshkr419 sandeshkr419 merged commit 50f2231 into opensearch-project:main Nov 19, 2025
93 of 99 checks passed
rgsriram pushed a commit to rgsriram/OpenSearch that referenced this pull request Dec 5, 2025
…ith Builder pattern (opensearch-project#20014)

Co-authored-by: Sandesh Kumar <sandeshkr419@gmail.com>
liuguoqingfz pushed a commit to liuguoqingfz/OpenSearch that referenced this pull request Dec 15, 2025
…ith Builder pattern (opensearch-project#20014)

Co-authored-by: Sandesh Kumar <sandeshkr419@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement or improvement to existing feature or request good first issue Good for newcomers Indexing Indexing, Bulk Indexing and anything related to indexing Other Search Search query, autocomplete ...etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] Use Builder pattern instead of constructors for Stats API classes

2 participants