Skip to content

Include histograms in sample_limit logic#17390

Merged
beorn7 merged 2 commits intoprometheus:mainfrom
prymitive:sample_limit
Oct 24, 2025
Merged

Include histograms in sample_limit logic#17390
beorn7 merged 2 commits intoprometheus:mainfrom
prymitive:sample_limit

Conversation

@prymitive
Copy link
Contributor

@prymitive prymitive commented Oct 23, 2025

Currently histograms bypass sample_limit logic as the limitAppender only implements the Append() method, while histograms are appended using AppendHistogram. This means that they are effectively ignored during sample_limit checks and a scrape with sample_limit=100 and 500 histograms will accept all samples. Add AppendHistogram method to the limitAppender so histograms are also counted towards sample_limit.

Which issue(s) does the PR fix:

Does this PR introduce a user-facing change?

[BUGFIX] Include histograms when enforcing sample_limit.

@beorn7 beorn7 self-requested a review October 24, 2025 08:16
Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

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

Thanks for catching this.

Currently histograms bypass sample_limit logic as the limitAppender only implements the Append() method, while histograms are appended using AppendHistogram.
This means that they are effectively ignored during sample_limit checks and a scrape with sample_limit=100 and 500 histograms will accept all samples.
Add AppendHistogram method to the limitAppender so histograms are also counted towards sample_limit.

Signed-off-by: Lukasz Mierzwa <l.mierzwa@gmail.com>
TestScrapeLoop_HistogramBucketLimit tests the bucket limiter but it also sets sample_limit to the same value, which seems incorrect.

Signed-off-by: Lukasz Mierzwa <l.mierzwa@gmail.com>
@beorn7
Copy link
Member

beorn7 commented Oct 24, 2025

Thanks again. 🚢

@beorn7 beorn7 merged commit 0ac7162 into prometheus:main Oct 24, 2025
28 checks passed
@prymitive prymitive deleted the sample_limit branch October 24, 2025 10:31
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