-
Notifications
You must be signed in to change notification settings - Fork 454
docs(logger): clarify Advanced Logging Controls interaction with sampling #7412
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
Conversation
…ling - Fix broken AWS Lambda ALC documentation link - Add warning about ALC interaction with log sampling - Clarify CDK applicationLogLevelV2 behavior with AWS_LAMBDA_LOG_LEVEL - Enhance priority section with concrete examples Fixes aws-powertools#7220
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.
Pull Request Overview
This PR improves documentation for AWS Lambda Advanced Logging Controls (ALC) interaction with Powertools Logger sampling functionality to reduce user confusion about unexpected logging behavior.
- Fixed broken AWS Lambda ALC documentation link
- Added warning about ALC interaction overriding sampling when log level is set to DEBUG
- Enhanced priority section with concrete examples showing Lambda log level precedence over Powertools configuration
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Hey @kattakaha thanks for sending this PR! At glance this PR looks ok, but I'll review this by the end of this week and work to get it merged! Thanks. |
@leandrodamascena friendly ping to remind you to review this tomorrow, if you can. |
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.
Hey @kattakaha! I just left some feedback before we merge it! Thanks so much for working on this.
docs/core/logger.md
Outdated
!!! info "AWS CDK and Advanced Logging Controls" | ||
When using AWS CDK's `applicationLogLevelV2` parameter or setting log levels through the Lambda console, AWS automatically sets the `AWS_LAMBDA_LOG_LEVEL` environment variable. This means Lambda's log level takes precedence over Powertools configuration, potentially overriding both `POWERTOOLS_LOG_LEVEL` and sampling settings. | ||
|
||
**Example**: If you set `applicationLogLevelV2=DEBUG` in CDK while having `POWERTOOLS_LOG_LEVEL=INFO`, the DEBUG level will be used because CDK automatically sets `AWS_LAMBDA_LOG_LEVEL=DEBUG` behind the scenes. |
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.
!!! info "AWS CDK and Advanced Logging Controls" | |
When using AWS CDK's `applicationLogLevelV2` parameter or setting log levels through the Lambda console, AWS automatically sets the `AWS_LAMBDA_LOG_LEVEL` environment variable. This means Lambda's log level takes precedence over Powertools configuration, potentially overriding both `POWERTOOLS_LOG_LEVEL` and sampling settings. | |
**Example**: If you set `applicationLogLevelV2=DEBUG` in CDK while having `POWERTOOLS_LOG_LEVEL=INFO`, the DEBUG level will be used because CDK automatically sets `AWS_LAMBDA_LOG_LEVEL=DEBUG` behind the scenes. | |
!!! info "AWS CDK and Advanced Logging Controls" | |
When using AWS CDK's `applicationLogLevelV2` parameter or setting log levels through the Lambda console, AWS Lambda automatically sets the `AWS_LAMBDA_LOG_LEVEL` environment variable. This means Lambda's log level takes precedence over Powertools for AWS configuration, potentially overriding both `POWERTOOLS_LOG_LEVEL` and sampling settings. | |
**Example**: If you set `applicationLogLevelV2=DEBUG` in CDK while having `POWERTOOLS_LOG_LEVEL=INFO`, the DEBUG level will be used because Lambda automatically sets the environment variable `AWS_LAMBDA_LOG_LEVEL` to the debug level. |
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.
docs/core/logger.md
Outdated
!!! warning "Interaction with AWS Lambda Advanced Logging Controls" | ||
When using [AWS Lambda Advanced Logging Controls](#aws-lambda-advanced-logging-controls-alc) with log level set to `DEBUG` (e.g., via CDK's `applicationLogLevelV2` or Lambda console), sampling may not work as expected. Lambda's log level setting takes precedence and overrides Powertools configuration, potentially causing all DEBUG logs to appear regardless of your sampling rate. See the [priority order](#aws-lambda-advanced-logging-controls-alc) for more details. | ||
|
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.
Please remove this here as it creates another block of tips/warnings and may clutter the page.
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.
Use sampling when you want to dynamically change your log level to **DEBUG** based on a **percentage of the Lambda function invocations**. | ||
|
||
You can use values ranging from `0.0` to `1` (100%) when setting `POWERTOOLS_LOGGER_SAMPLE_RATE` env var, or `sampling_rate` parameter in Logger. | ||
|
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.
Please add this new line here
AWS Lambda Advanced Logging Controls (ALC) settings can affect Sampling behavior. See how it works.
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.
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.
Please address the changes.
@leandrodamascena Thanks for the detailed feedback! I've addressed all the requested changes:
The documentation should now be clearer and less repetitive. Please let me know if anything else needs adjustment. |
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.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
docs/core/logger.md
Outdated
|
||
Example: Imagine an e-commerce checkout process where you want to understand rare payment gateway errors. With 10% sampling, you'll log detailed information for a small subset of transactions, making troubleshooting easier without generating excessive logs. | ||
|
||
|
Copilot
AI
Sep 26, 2025
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.
Remove the extra blank line at line 840. This creates unnecessary whitespace in the documentation.
Copilot uses AI. Check for mistakes.
- Update CDK example wording for precision - Remove warning block from sampling section - Add ALC reference to sampling introduction
|
Sorry for the confusion with the commit history. I've recreated this PR with a cleaner commit structure. Please see the new PR: #7413 |
Issue number: closes #7220
Summary
Changes
This PR addresses documentation improvements for AWS Lambda Advanced Logging Controls (ALC) interaction with Powertools Logger sampling functionality. The changes clarify how Lambda's log level settings override Powertools configuration and provide clear guidance to avoid confusion.
applicationLogLevelV2
behavior withAWS_LAMBDA_LOG_LEVEL
environment variableUser experience
Before: Users were confused about the interaction between Lambda's Advanced Logging Controls and Powertools sampling settings, leading to unexpected behavior where sampling didn't work as expected when ALC was set to DEBUG level.
After: Users have clear documentation explaining:
applicationLogLevelV2
automatically setsAWS_LAMBDA_LOG_LEVEL
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.