[Sampler.AWS] Limit the max size read for response body getting the sampling rules to 1MB.#4100
Merged
Kielek merged 4 commits intoopen-telemetry:mainfrom Apr 14, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4100 +/- ##
==========================================
+ Coverage 72.93% 72.96% +0.03%
==========================================
Files 452 453 +1
Lines 17844 17890 +46
==========================================
+ Hits 13014 13054 +40
- Misses 4830 4836 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
martincostello
approved these changes
Apr 14, 2026
Kielek
approved these changes
Apr 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a defensive cap (1MB) when reading AWS X-Ray sampling rules/targets responses to reduce risk from unexpectedly large/untrusted HTTP payloads.
Changes:
- Introduce
LimitedStreamstream wrapper enforcing a maximum number of bytes read. - Update
AWSXRaySamplerClient.DoRequestAsyncto read via stream +LimitedStreaminstead ofReadAsStringAsync. - Add unit tests for
LimitedStreamand update package changelog.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/OpenTelemetry.Sampler.AWS/AWSXRaySamplerClient.cs |
Switch response reading to a streamed approach with a 1MB cap. |
src/OpenTelemetry.Sampler.AWS/LimitedStream.cs |
New stream wrapper enforcing a max-bytes-read limit. |
test/OpenTelemetry.Sampler.AWS.Tests/TestLimitedStreamReader.cs |
New tests validating LimitedStream behavior. |
src/OpenTelemetry.Sampler.AWS/CHANGELOG.md |
Document the new 1MB response-size limit behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 #
Changes
Makes the code reading X-Ray sampling rules more defensive reading the response back from the sampling endpoint. Limits the max read for sampling rules to 1 MB. Well beyond what sampling rules max should be as long as the code is receiving valid sampling rules.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes[ ] Changes in public API reviewed (if applicable)