Open
Description
Expected Behavior
logger.info
or any logger calls should not be using excessive memory usage with
Max Memory Used: 3339 MB
This is opposed to straight console.log
, where we get
Max Memory Used: 83 MB
Current Behavior
See the executions logs.
When we run the simple code snippet with powertools logger logger.info
, high memory usage is recorded.
Max Memory Used: 3339 MB
Code snippet
var serviceName = 'exampleService';
var logger = new Logger({ serviceName });
var handler = async (event, context) => {
let largeObject = {
prop1: 'prop',
prop2: 'prop',
prop3: 'prop',
prop4: 'prop',
prop5: 'prop',
prop6: 'prop',
prop7: 'prop',
prop8: 'prop',
prop9: 'prop',
prop10: 'prop',
prop11: 'prop',
prop12: 'prop',
prop13: 'prop',
prop14: 'prop',
prop15: 'prop',
prop16: 'prop',
prop17: 'prop',
prop18: 'prop',
prop19: 'prop',
prop20: 'prop',
prop21: 'prop',
prop22: 'prop',
prop23: 'prop',
prop24: 'prop',
prop25: 'prop',
prop26: 'prop',
prop27: 'prop',
prop28: 'prop',
};
logger.info(JSON.stringify(event));
logger.info(JSON.stringify(context));
logger.info('hello world');
for (let i = 0; i < 100000; i++) {
logger.info(`hello world`, { largeObject });
logger.info(`hello world`, { largeObject });
logger.info(`hello world`, { largeObject });
logger.info(`hello world`, { largeObject });
logger.info(`hello world`, { largeObject });
logger.info(`hello world`, { largeObject });
logger.info(`hello world`, { largeObject });
// console.log(`hello world`, { largeObject });
// console.log(`hello world`, { largeObject });
// console.log(`hello world`, { largeObject });
// console.log(`hello world`, { largeObject });
// console.log(`hello world`, { largeObject });
// console.log(`hello world`, { largeObject });
// console.log(`hello world`, { largeObject });
}
return 'done';
};
Steps to Reproduce
- Entire handler code posted in
Code snippet
- Create lambda with runtime environment nodejs-18.x
- install latest
@aws-lambda-powertools/logger
, and import - run code snippet with lambda
Possible Solution
Could this be related to the internal buffer powertools logger is setting? There is a buffer before the logger instance is initialized, but I am unsure what is happening during initialization.
Powertools for AWS Lambda (TypeScript) version
2.7.0
AWS Lambda function runtime
18.x
Packaging format used
npm
Execution logs
with powertools logger:
REPORT RequestId: <redacted> Duration: 29762.11 ms Billed Duration: 29763 ms Memory Size: 10240 MB Max Memory Used: 3339 MB
with console.log:
REPORT RequestId: <redacted> Duration: 21149.55 ms Billed Duration: 21150 ms Memory Size: 10240 MB Max Memory Used: 83 MB Init Duration: 200.98 ms
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
On hold