-
Notifications
You must be signed in to change notification settings - Fork 154
Bug: Log pollution with the same warning on every warm execution when using injectLambdaContext middleware #3815
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hi @kallependers, thank you for opening this issue and for taking the time to share the detailed report. I was able to reproduce the issue and as you pointed out, when the we detect that Advanced Logging Controls is enabled we fall back to that, but never store that value. Because of this, even if I'm working to see if I can fix the bug and will propose a PR, hopefully soon. We do have a section dedicated to ALC and how it interacts with our logger here, if you think there's any specific improvement we can do there please let us know. |
Besides fixing the bug described above, I think we should also address the fact that these warnings should not be spammed. I'm going to see if I can implement a mechanism to emit this type of warnings only once per execution environment. |
Sounds great! Thanks a lot for the quick response. |
This issue is now closed. Please be mindful that future comments are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so. |
This is now released under v2.19.0 version! |
Expected Behavior
No warning logged that the current log level does not match AWS Lambda Advanced Logging Controls minimum log level when
injectLambdaContext
Middy middleware is used.Current Behavior
On every warm execution with
injectLambdaContext
Middy middleware a warning is logged that the current log level does not match AWS Lambda Advanced Logging Controls minimum log level.Problem:
injectLambdaContext
callsrefreshSampleRateCalculation
on every execution;refreshSampleRateCalculation
callsthis.setLogLevel
with the#initialLogLevel
on every warm call when debug sampling is not enabled;Since the following commit 8c8d6b2, because
refreshSampleRateCalculation
was added tomiddy.ts
.Code snippet
Steps to Reproduce
systemLogLevelV2
);POWERTOOLS_LOG_LEVEL=WARN
;injectLambdaContext
Middy middleware;Possible Solution
setInitialLogLevel
inLogger.ts
assigns the#initialLogLevel
regardless if awsLogLevelShortCircuit is true and another check is added (or replaced for theawsLogLevelShortCircuit
condition insetInitialLogLevel
) if AWS Lambda Advanced Logging Controls is configured and sets the initial log level with this value.Another solution would be documenting that Powertool's log level should be combined with AWS Lambda's application log level. The downside of this would be possible log pollution coming from libraries that don't use the Powertool logger, but something else (console eg).
Powertools for AWS Lambda (TypeScript) version
V2.16.0 - V2.18.0 (latest currently)
AWS Lambda function runtime
22.x
Packaging format used
npm
Execution logs
The text was updated successfully, but these errors were encountered: