Prevent S3 URL presigning from generating a remote request span #1494
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 #922
This PR addresses
ddtrace
capturing a "fake" S3 request that the AWS S3 SDK reports when presigning a request URL.Presigned URLs give users a pre-authenticated URL to be used in the future to retrieve data from S3, but they do not preform any data retrieval to get created.
The Ruby S3 SDK performs a "fake" request internally to generated a presigned URL: it creates an S3
get_object
request, sends it through the regular request handler (one of which beingDatadog::Contrib::Aws::Handler
), but hijacks the "data send" step at the end by not actually sending the request.Unfortunately, there's no data we can use to differentiate between a real request and a fake request in our
ddtrace
handler. I've opened a PR with AWS to provide us with that information, so we can simplify the logic from this PR in the future: aws/aws-sdk-ruby#2513This PR effectively removes our request handler from these fake presign requests, the same approach taken internally by the S3 SDK for some of its own handlers that do not play nice with the fake presign request: https://github.com/aws/aws-sdk-ruby/blob/656691b470bb970627286cf1df2bd84049b6787d/gems/aws-sdk-s3/lib/aws-sdk-s3/presigner.rb#L194-L196