Closed
Description
Expected Behavior
Invoking a hot Lambda function refreshes the sampling decision. This results in that log level being sometimes lowered to DEBUG
based on my set sampleRateValue
.
Current Behavior
Invoking a hot Lambda function does not refresh the sampling decision. The sampling decision seems to only happen on Logger initialization.
Code snippet
The Lambda function uses the POWERTOOLS_LOGGER_SAMPLE_RATE
environment variable with a value of 0.5
.
import { Logger } from '@aws-lambda-powertools/logger';
const logger = new Logger({
serviceName: 'powertools-logger-test',
});
export const handler = async () => {
logger.refreshSampleRateCalculation();
logger.debug('visible sometimes');
logger.info('@aws-lambda-powertools/logger" = 2.xx');
};
Steps to Reproduce
- Create a Lambda function according to the provided code snippet.
- Ensure that the Lambda function uses the
POWERTOOLS_LOGGER_SAMPLE_RATE
environment variable and that it has a high percentage to lower the log level. - Install version
2.15.0
of the@aws-lambda-powertools/logger
, deploy the function, and invoke it a few times to confirm that theDEBUG
log level is sometimes used. - Install version
2.16.0
of the@aws-lambda-powertools/logger
, deploy the function, and invoke it a few times. TheDEBUG
log level will be used for all invocations or none of them (refreshSampleRateCalculation
function has no effect).
Possible Solution
No response
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped