-
Notifications
You must be signed in to change notification settings - Fork 153
feat(logger): Flush buffer on uncaught error in Middy middleware #3690
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): Flush buffer on uncaught error in Middy middleware #3690
Conversation
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 Connor! Left a couple comments here & there but I think we are very close
The clearBuffer method clears the logger buffer.
35095d9
to
02e1440
Compare
|
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 work on this feature, Connor!
This should be the last PR for this feature - we'll write the docs in the next days and expect to ship it on Friday.
Summary
This PR adds support for flushing the log buffer when an uncaught error is encountered using middy middleware.
Changes
flushBufferOnUncaughtError
option to middyinjectLambdaContext
optionsclearBuffer
method to the logger. This is needed to clear the buffer in theonAfter
handler. An alternative I considered was changing the logic of the buffer to only handle one trace id at a time. If a log is buffered with a new trace ID, then the buffer could be reset.injectLambdaContextAfterOrOnError
into separate handlers . Simplify the names all the handlers.Notes
target
parameter ofinjectLambdaContext
can be an array of loggers. I wasn't clear on the correct behaviour if there are multiple loggers provided. At the moment it will flush each logger.Issue number: #3633
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.