Skip to content

feat(metrics): add clear_all to stop reporting unchanged series - #280

Open
MariamFahmy98 wants to merge 2 commits into
cloudflare:mainfrom
MariamFahmy98:OBS-8124
Open

MariamFahmy98 wants to merge 2 commits into
cloudflare:mainfrom
MariamFahmy98:OBS-8124

Conversation

@MariamFahmy98

Copy link
Copy Markdown

A draining process keeps exporting every series it ever created, even though most of them stop changing once it no longer serves traffic.

This PR adds a clear_all functionality, which snapshots the value of every registered series. Collection then skips each series whose value still matches the snapshot. A series that changes is reported with its current value and stays reported, so graphs don't get gaps. Series and metrics created after the call, and info metrics, are always reported. Values aren't reset, so existing handles keep working, and calling it again starts over from the values at that time.

Also, RangeGauge resets its min and max when read, so the snapshot reads each metric twice and keeps the second result. Without that, an idle gauge would never match and would be reported forever.

Signed-off-by: Mariam <mariam@cloudflare.com>
Comment thread foundations-metrics/src/clear.rs Outdated
Comment thread foundations-metrics/src/clear.rs Outdated
Signed-off-by: Mariam <mariam@cloudflare.com>
@MariamFahmy98
MariamFahmy98 marked this pull request as ready for review October 22, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants