-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(aws-sdk): avoid repeating MessageAttributeNames in sqs receiveMessage #1044
Conversation
Co-authored-by: Kent Quirk <[email protected]> Co-authored-by: Purvi Kanal <[email protected]> Co-authored-by: Mike Goldsmith <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #1044 +/- ##
==========================================
+ Coverage 95.91% 95.95% +0.04%
==========================================
Files 13 24 +11
Lines 856 1410 +554
Branches 178 295 +117
==========================================
+ Hits 821 1353 +532
- Misses 35 57 +22
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix
Can you please add a test for this case?
We're having some trouble figuring out how to test Our understanding at the moment is that In To help us move forward, we'd love some help answering the following questions:
|
Co-authored-by: Purvi Kanal <[email protected]>
Thank you for doing the research
If I understand SQS correctly, this filtering is done in the server itself, so the request contains which message attributes to include in the response and then the server copies them to "receiveMessages" response.
The tests for this instrumentation use a mock to return responses and validate the request parameters. This is done, for example, here. I think a proper test might be to assert that the request that is "sent" to the mock server does not repeat the propagators fields in
I don't know how an actual SQS server is implemented to behave if multiple names are sent in the request, it could repeat them in response or just return each one of them once. The original issue if I understood it correctly is due to the request itself being invalid due to the size (These attribute names are just keep piling up forever until the limit is hit). The response in the test is mocked and will not follow the semantics of AWS.
I can think of 2 possible ways to test it:
return Array.from(
new Set([
...(origMessageAttributeNames ?? []),
...propagation.fields(),
])
); |
plugins/node/opentelemetry-instrumentation-aws-sdk/src/services/sqs.ts
Outdated
Show resolved
Hide resolved
… tests Co-authored-by: Jamie Danielson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding the test
Added 2 suggestions
plugins/node/opentelemetry-instrumentation-aws-sdk/src/services/sqs.ts
Outdated
Show resolved
Hide resolved
plugins/node/opentelemetry-instrumentation-aws-sdk/src/services/sqs.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Purvi Kanal <[email protected]>
I just wanted to leave a quick note indicating that we have tested this patch and I can confirm it resolves the issue described in #1038 Thank you @JamieDanielson, we will look forward to this getting this merged and released. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for addressing all comments 💯
Left a small optional nit about the function name
plugins/node/opentelemetry-instrumentation-aws-sdk/src/services/MessageAttributes.ts
Outdated
Show resolved
Hide resolved
@JamieDanielson @pkanal , I think this is ready to be merged. Thanks again for working on this fix. |
…sage (open-telemetry#1044) * fix(instrumentation-aws-sdk): dedupe prop fields Co-authored-by: Kent Quirk <[email protected]> Co-authored-by: Purvi Kanal <[email protected]> Co-authored-by: Mike Goldsmith <[email protected]> * fix linting * add test for message attributes Co-authored-by: Purvi Kanal <[email protected]> * test both messages * deduplicate message attribute names in seperate function and add unit tests Co-authored-by: Jamie Danielson <[email protected]> * remove line to force ci checks * appease linter Co-authored-by: Purvi Kanal <[email protected]> * appease linter * move logic into dedupe function and add unit tests * rename helper function to be more descriptive Co-authored-by: Kent Quirk <[email protected]> Co-authored-by: Purvi Kanal <[email protected]> Co-authored-by: Mike Goldsmith <[email protected]> Co-authored-by: Mike Goldsmth <[email protected]> Co-authored-by: Purvi Kanal <[email protected]> Co-authored-by: Jamie Danielson <[email protected]> Co-authored-by: Purvi Kanal <[email protected]>
Which problem is this PR solving?
If duplicate requests are storing the same value multiple times, this will address the problem by passing the
MessageAttributeNames
through a Set to de-duplicate them.It's unclear why these duplicates are happening and adding the same value multiple times, so that is still an issue to be looked into. It is not solved by this PR. This PR is also not attempting to measure the size of the attributes to determine whether the size is under the required 256KB.
413 REQUEST ENTITY TOO LARGE
#1038Short description of the changes
Checklist
npm run test-all-versions
for the edited package(s) on the latest commit if applicable.