Skip to content

stats: consolidate iteration via IterationCriteria#44296

Open
sxl613 wants to merge 1 commit intoenvoyproxy:mainfrom
sxl613:main
Open

stats: consolidate iteration via IterationCriteria#44296
sxl613 wants to merge 1 commit intoenvoyproxy:mainfrom
sxl613:main

Conversation

@sxl613
Copy link
Copy Markdown

@sxl613 sxl613 commented Apr 6, 2026

Ref: #44156

Store previously had 8 virtual forEach methods: forEachCounter, forEachGauge, forEachTextReadout, forEachHistogram, and a parallel forEachSinked* family for each.
The sinked variants were functionally identical to the non-sinked variants except for a filter.
This PR collapses them into 4 methods by introducing an IterationCriteria struct.

A struct over a naked bool since it reads clearly (with the help of designated initializers) and allows for more filter fields in the future. #44156 mentions one for used_only, I've not added that one since I felt like a smaller change would be best to start with.

There were three differences between the sinked and non-sinked variants in Allocator that I preserved in the merged implementation:

  1. Missing f_size nullptr checks in the sinked variants; the merged implementation adds them in both cases
  2. Gauges have a hidden() filter applied when iterating sinked stats with no sink predicates
  3. Sinked iteration falls back to all stats when sink_predicates_ is not set

Risk Level: Low
Testing: adapted existing tests only
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Claude Code was used to help navigate the codebase and understand the existing implementation prior to making changes.

Ref: envoyproxy#44156

Reduces 8 virtual forEach methods to 4 by introducing IterationCriteria,
a struct that carries iteration filters (currently sinked_only).
This eliminates duplication between forEachCounter/forEachSinkedCounter
and equivalents for Gauge, TextReadout, and Histogram.

Signed-off-by: Szczepan Lukowski <szczepan.lukowski@gmail.com>
@repokitteh-read-only
Copy link
Copy Markdown

Hi @sxl613, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #44296 was opened by sxl613.

see: more, trace.

@jmarantz
Copy link
Copy Markdown
Contributor

jmarantz commented Apr 7, 2026

Hi -- sorry you wasted some tokens generating this. This is actually going to massively conflict with my in-progress #44285 so I'd prefer not to pursue reviewing this PR.

@phlax
Copy link
Copy Markdown
Member

phlax commented Apr 13, 2026

/wait-any

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