Conversation
The per-request samples limit only counted float samples (len(timeseries.Samples)) before calling AllowSamples. Native histogram data points were ignored, so a request could carry an unbounded number of histograms without ever hitting the limit. Count len(timeseries.Histograms) toward the same limit in both the Prometheus remote-write path (handler.go) and the OTLP path (handler_otlp.go), and extend TestReceiveWriteRequestLimits to cover a request that stays under the limit on floats alone but exceeds it once histograms are included. Closes thanos-io#7593 Signed-off-by: lemon0333 <147061193+lemon0333@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8987 +/- ##
=======================================
Coverage 64.54% 64.54%
=======================================
Files 289 289
Lines 37352 37352
=======================================
+ Hits 24108 24110 +2
+ Misses 11150 11148 -2
Partials 2094 2094 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
GiedriusS
reviewed
Aug 24, 2026
| amountSamples: 2, | ||
| }, | ||
| { | ||
| // Floats alone (10*10=100) stay under the 200 samples limit, but once |
Member
There was a problem hiding this comment.
Remove this useless comment, please.
This was referenced Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7593
Changes
The Receive per-request
sampleslimit only counted float samples when deciding whether to reject a write request as "too many samples". Native histogram data points were not counted, so a request could carry an unbounded number of native histograms without ever hitting the configured samples limit.This changes the sample counting to also include native histograms:
pkg/receive/handler.go: the Prometheus remote-write path now sumslen(timeseries.Samples) + len(timeseries.Histograms)before callingrequestLimiter.AllowSamples(...).pkg/receive/handler_otlp.go: the OTLP path applies the same inclusion.Scope is intentionally kept tight to the existing
sampleslimit. The separatetotal_histogram_samples/ total-buckets limits mentioned as larger alternatives in #7593 can be a follow-up.Verification
go build ./pkg/receive/...passes.go test ./pkg/receive/ -run TestReceiveWriteRequestLimitspasses, including a new sub-caseRequest above limit of samples once native histograms are counted: with a samples limit of 200, a request of 10 series × 10 float samples (100 total) stays under the limit on floats alone, but once 10 series × 11 native histograms (110) are also counted the total (210) exceeds the limit and the request is rejected with413 Request Entity Too Large. This fails without the change and passes with it.gofmtandgo vet ./pkg/receive/are clean.