Register status_counter as filterable index metric in node stats API - #22388
Register status_counter as filterable index metric in node stats API#22388gingeekrishna wants to merge 3 commits into
Conversation
status_counter was introduced via opensearch-project#19115 but was never added to CommonStatsFlags.Flag, so it was always included in node stats responses regardless of which specific index metric was requested. Callers targeting a single metric such as: GET _nodes/stats/indices/request_cache consistently received status_counter alongside the requested metric. Fix: add Flag.StatusCounter("status_counter", 17) to CommonStatsFlags. RestNodesStatsAction already builds its FLAGS map by iterating all Flag values, so the new flag is auto-registered as a valid filterable metric name. IndicesService.stats() now gates statusCounterStats on flags.isSet(Flag.StatusCounter) so the field is only included when explicitly requested (or when _all metrics are requested). Fixes opensearch-project#22383 Signed-off-by: Radhakrishnan Pachyappan <gingeekrishnan@gmail.com>
PR Reviewer Guide 🔍(Review updated until commit 14b0dcd)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 14b0dcd Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 58b6df7
Suggestions up to commit 52b968a
Suggestions up to commit 5506edf
Suggestions up to commit 52b968a
|
|
Persistent review updated to latest commit 5506edf |
|
❌ Gradle check result for 5506edf: 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? |
5506edf to
52b968a
Compare
|
Persistent review updated to latest commit 52b968a |
|
❌ Gradle check result for 52b968a: 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? |
|
Persistent review updated to latest commit 58b6df7 |
|
❌ Gradle check result for 58b6df7: 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? |
|
Persistent review updated to latest commit 14b0dcd |
|
❌ Gradle check result for 14b0dcd: 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? |
Description
Fixes #22383
status_counterwas introduced in #19115 but was never added toCommonStatsFlags.Flag. As a result, it was always included in everyGET _nodes/stats/indices/<metric>response regardless of which specific metric was requested — contrary to how all other index-level metrics behave.Root cause
RestNodesStatsActionbuilds its filterable-metric map (FLAGS) by iteratingCommonStatsFlags.Flag.values(). Sincestatus_counterhad noFlagentry, it was invisible to the filtering layer.IndicesService.stats()then unconditionally passedstatusCounterStatstoNodeIndicesStatsregardless of what the caller requested.Fix
Two small changes:
CommonStatsFlags.java: AddStatusCounter("status_counter", 17)to theFlagenum. This automatically registersstatus_counteras a valid, filterable index metric inRestNodesStatsActionwithout any additional wiring.IndicesService.java: GatestatusCounterStatsonflags.isSet(Flag.StatusCounter). TheNodeIndicesStatsconstructors already acceptnullforstatusCounterStatsand omit the field when null, so the existing null-guard at the rendering layer handles this cleanly.Behaviour after fix
status_counterincluded?GET _nodes/stats(all)GET _nodes/stats/indices(all indices metrics)GET _nodes/stats/indices/status_counterGET _nodes/stats/indices/request_cacheGET _nodes/stats/indices/segmentsTesting
Compilation confirmed clean. Integration test coverage for the node stats filtering framework already exists in
NodeStatsIT; the new flag follows the same pattern as all existing flags and is exercised by the same test infrastructure.