-
Notifications
You must be signed in to change notification settings - Fork 429
feat(parser): add support to decompress Kinesis CloudWatch logs in Kinesis envelope #6656
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
feat(parser): add support to decompress Kinesis CloudWatch logs in Kinesis envelope #6656
Conversation
…ntains compressed data
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
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.
Hi @Artur-T-Malas, thanks for working on this PR! Overall it looks good to me, but our CI is failing with some linting error. Can you run make format
and commit again? I tried that, but you didn't give me access to modify your branch.
Hi @leandrodamascena, thank you. I ran |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #6656 +/- ##
========================================
Coverage 96.11% 96.11%
========================================
Files 253 253
Lines 12160 12170 +10
Branches 904 904
========================================
+ Hits 11687 11697 +10
Misses 371 371
Partials 102 102 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…h Logs from Kinesis envelope
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.
Hi @Artur-T-Malas, we are almost there! There is a test missing where customer uses data that is not binary and not Gizp. You can check the missing lines here: https://app.codecov.io/gh/aws-powertools/powertools-lambda-python/pull/6656?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-powertools
I could push a commit to fix this and merge this PR, but you haven't given access to your branch, so please fix this before we merge.
Hi @Artur-T-Malas, I saw your invite to collaborate on your repository, but we don't actually need that. Just give me permission on your branch: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork Thanks |
Hi @leandrodamascena! I've read the support article which you've linked, and the "Allow edits by maintainers" option seems to be already enabled. Are there any additional steps to it which I'm missing? My apologies, I'm very new to collaborating on GitHub. About the missing test coverage on the lines 62 and 63
I believe that I have covered them in this test, which modifies the
Please correct me if I'm wrong or I have misunderstood your comment. Thank you! |
|
Hi, it's working now and no need to apologize, we love it when people come together to contribute to Powertools. Feel free to pick any issue to solve, I'll be happy to help.
Actually you are right, this test covers this scenario, but the problem was that you were sending plain text data in the Thanks a lot for working on this. |
I'm glad that I could contribute to this amazing tool! Thank you for explaining the test issue to me and fixing it. Indeed the base64 encoding must've escaped me. |
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.
Approved!!!
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
Issue number: #6625
Summary
This feature allows parsing of CloudWatch Logs data using a
KinesisDataStreamEnvelope
.Changes
In the
utilities/parser/envelopes/kinesis.py
file: Extracted and wrapped thedata.decode("utf-8")
operation frommodels.append(self._parse(data=data.decode("utf-8"), model=model))
line, inside atry/except
block, to catch theUnicodeDecodeError
. This error indicates that the data might be compressed, so in theexcept
block there is anothertry/except
block added with a decompression step before the decoding.Added a test in the
tests/unit/parser/_pydantic/test_kinesis.py
file:User experience
Before, as reported in the issue #6648, trying to parse an event using
KinesisDataStreamEnvelope
to get CloudWatch Logs compressed data resulted in theUnicodeDecodeError
being thrown.This change enables that workflow.
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.