Skip to content

Conversation

tcard
Copy link
Contributor

@tcard tcard commented Sep 24, 2025

What this PR does

In the Prometheus push endpoint, when the write request after compression exceeds the limit, the HTTP request's content length (this before compression) would be reported, so you could see an error like this:

the incoming push request has been rejected because its message size of 16245 bytes is larger than the allowed limit of 100000 bytes

With this change:

  • Compressed and uncompressed sizes are now handled explicitly.
  • The error message always has either (compressed) or (uncompressed) to make it always clear which one it's talking about.
  • The implementation of the several "message too large" error types have been made uniform.

Which issue(s) this PR fixes or relates to

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]. If changelog entry is not needed, please add the changelog-not-needed label to the PR.
  • about-versioning.md updated with experimental features.

@tcard tcard requested a review from a team as a code owner September 24, 2025 10:26
Copy link
Contributor

@56quarters 56quarters left a comment

Choose a reason for hiding this comment

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

Approved with a few comments.

} else if e.compressed > 0 {
msgSizeDesc = fmt.Sprintf(" of %d bytes (compressed)", e.compressed)
}
return globalerror.DistributorMaxOTLPRequestSize.MessageWithPerInstanceLimitConfig(fmt.Sprintf("the incoming OTLP request has been rejected because its message size%s is larger than the allowed limit of %d bytes", msgSizeDesc, e.limit), maxOTLPRequestSizeFlag)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to not have either the compressed or actual size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because we only decompress requests until reaching the limit, so we don't exactly know by how much a compressed request is over the limit after decompression.

I added a specific constructor for this case at 8250a2f.

responseContentLength: 292,
errMessage: "the incoming OTLP request has been rejected because its message size of 89 bytes is larger",
expectedLogs: []string{`level=warn user=test msg="detected an error while ingesting OTLP metrics request (the request may have been partially ingested)" httpCode=413 err="rpc error: code = Code(413) desc = the incoming OTLP request has been rejected because its message size of 89 bytes is larger than the allowed limit of 30 bytes (err-mimir-distributor-max-otlp-request-size). To adjust the related limit, configure -distributor.max-otlp-request-size, or contact your service administrator." insight=true`},
responseContentLength: 307,
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that this isn't new but this seems very fragile. Where does this number come from? Can we verify it some other way?

expectedLogs: []string{`level=warn user=test msg="detected an error while ingesting OTLP metrics request (the request may have been partially ingested)" httpCode=413 err="rpc error: code = Code(413) desc = the incoming OTLP request has been rejected because its message size of 106 bytes is larger than the allowed limit of 30 bytes (err-mimir-distributor-max-otlp-request-size). To adjust the related limit, configure -distributor.max-otlp-request-size, or contact your service administrator." insight=true`},
responseContentLength: 308,
errMessage: "the incoming OTLP request has been rejected because its message size of 106 bytes (decompressed) is larger",
expectedLogs: []string{`level=warn user=test msg="detected an error while ingesting OTLP metrics request (the request may have been partially ingested)" httpCode=413 err="rpc error: code = Code(413) desc = the incoming OTLP request has been rejected because its message size of 106 bytes (decompressed) is larger than the allowed limit of 30 bytes (err-mimir-distributor-max-otlp-request-size). To adjust the related limit, configure -distributor.max-otlp-request-size, or contact your service administrator." insight=true`},
Copy link
Contributor

Choose a reason for hiding this comment

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

Personal preference but I really don't like testing for extremely specific log messages like this. It makes the tests fragile and is testing for implementation specific side-effects instead of the response for the method on question.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had the same thought (also about #12799 (comment)) while updating those tests, but I wanted to keep the PR focused.

I'll open a separate PR relaxing those tests.

@tcard tcard requested a review from 56quarters September 24, 2025 15:18
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