-
Notifications
You must be signed in to change notification settings - Fork 153
feat(logger): add circular buffer #3593
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(logger): add circular buffer #3593
Conversation
Hi @VatsalGoel3, thank you for the PR. Could you please restore the PR template instead of rewriting it from scratch? |
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 @VatsalGoel3, great PR so far!
Left a few notes that I'd like us to address before moving forward, let me know if you have any questions.
I've incorporated the requested changes and made a few refinements: Refactored the test for buffer overflow eviction Removed JSON.stringify() in SizedItem
|
|
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 the PR and for addressing my comments!
I'm going to be creating several more issues that open for contributions in the next day or so, if you're interested keep an eye out.
Summary
This PR adds a new log buffering module for the logger package.
Changes
SizedItem
: Encapsulates a log entry and calculates its byte size using JSON serialization.SizedSet
: ExtendsSet
to track the cumulative size of log entries and provides a FIFO removal method viashift()
.CircularMap
: Maps request identifiers toSizedSet
buffers, enforces a maximum buffer size (in bytes), and evicts the oldest entries when necessary. Includes an optionalonBufferOverflow
callback.packages/logger/tests/unit/logBuffer.test.ts
) to validate the log buffering module.Issue number: closes #3589
By submitting this pull request, I confirm that I have read and followed the Powertools for AWS Lambda (TypeScript) contributing guidelines, and I confirm that you can use, modify, copy, and redistribute this contribution under the terms of your choice.