Skip to content

Conversation

@dependabot
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Mar 10, 2025

Bumps aws-lambda-powertools from 2.35.1 to 3.8.0.

Release notes

Sourced from aws-lambda-powertools's releases.

v3.8.0

Summary

We are excited to announce a new feature in Logger: Logger buffering. This new feature allows you to buffer logs for a specific invocation, and flush them automatically on error or manually as needed.

A special thanks to Ollie Saul and James Saull from Dotelastic for their instrumental input on this new feature!

⭐ Also, huge thanks to our new contributors: @​tiagohconte and @​speshak.

New Log Buffering feature

Docs

You can now enable log buffering by passing buffer_config when initializing a new Logger instance. This feature allows you to:

  • Buffer logs at the WARNING, INFO, and DEBUG levels
  • Automatically flush logs on error or manually as needed
  • Reduce CloudWatch costs by decreasing the number of emitted log messages

buffer1

Configuration options

Option Description Default
max_bytes Maximum size of the buffer in bytes 20480
buffer_at_verbosity Minimum log level to buffer (more verbose levels are also buffered) DEBUG
flush_on_error_log Whether to flush buffer when an error is logged True

When log buffering is enabled, you can now pass a new opt-in flush_buffer_on_uncaught_error flag to the inject_lambda_context() decorator. When enabled, 1/ we'll intercept any raised exception, 2/ flush the buffer, and 3/ re-raise your original exception. This enables you to have detailed logs from your application when you need them the most.

buffer3

For detailed explanations with diagrams, please refer to our comprehensive documentation.

Buffering FAQs

Q: Does the buffer persist across Lambda invocations? A: No, each Lambda invocation has its own buffer. The buffer is initialized when the Lambda function is invoked and is cleared after the function execution completes or when flushed manually.

Q: Are my logs buffered during cold starts? A: No. We never buffer logs during cold starts to ensure all logs from this phase are immediately available for debugging.

Q: How can I prevent log buffering from consuming excessive memory? A: You can limit the size of the buffer by setting the max_bytes option in the LoggerBufferConfig constructor parameter. This will ensure that the buffer does not grow indefinitely and consume excessive memory.

Q: What happens if the log buffer reaches its maximum size? A: Older logs are removed from the buffer to make room for new logs. This means that if the buffer is full, you may lose some logs if they are not flushed before the buffer reaches its maximum size. When this happens, we emit a warning when flushing the buffer to indicate that some logs have been dropped.

... (truncated)

Changelog

Sourced from aws-lambda-powertools's changelog.

[v3.8.0] - 2025-03-07

Bug Fixes

  • event_handler: revert regression when validating response (#6234)

Code Refactoring

  • tracer: fix capture_lambda_handler return type annotation (#6197)

Documentation

  • layer: Fix SSM parameter name for looking up layer ARN (#6221)

Features

  • logger: add logger buffer feature (#6060)
  • logger: add new logic to sample debug logs (#6142)

Maintenance

  • version bump
  • ci: new pre-release 3.7.1a2 (#6186)
  • ci: new pre-release 3.7.1a0 (#6166)
  • ci: new pre-release 3.7.1a6 (#6229)
  • ci: new pre-release 3.7.1a7 (#6233)
  • ci: new pre-release 3.7.1a1 (#6178)
  • ci: enable SAR deployment (#6104)
  • ci: new pre-release 3.7.1a5 (#6219)
  • ci: new pre-release 3.7.1a3 (#6201)
  • ci: new pre-release 3.7.1a4 (#6211)
  • deps: bump docker/setup-qemu-action from 3.5.0 to 3.6.0 (#6190)
  • deps: bump actions/download-artifact from 4.1.8 to 4.1.9 (#6174)
  • deps: bump squidfunk/mkdocs-material from 2615302 to 047452c in /docs (#6210)
  • deps: bump docker/setup-qemu-action from 3.4.0 to 3.5.0 (#6176)
  • deps: bump docker/setup-buildx-action from 3.9.0 to 3.10.0 (#6175)
  • deps: bump datadog-lambda from 6.105.0 to 6.106.0 (#6218)
  • deps: bump codecov/codecov-action from 5.3.1 to 5.4.0 (#6180)
  • deps: bump pydantic-settings from 2.8.0 to 2.8.1 (#6182)
  • deps: bump jinja2 from 3.1.5 to 3.1.6 in /docs (#6223)
  • deps-dev: bump cdklabs-generative-ai-cdk-constructs from 0.1.294 to 0.1.295 (#6207)
  • deps-dev: bump cdklabs-generative-ai-cdk-constructs from 0.1.293 to 0.1.294 (#6193)
  • deps-dev: bump aws-cdk-aws-lambda-python-alpha from 2.181.0a0 to 2.181.1a0 (#6194)
  • deps-dev: bump ruff from 0.9.8 to 0.9.9 (#6195)
  • deps-dev: bump aws-cdk-lib from 2.181.1 to 2.182.0 (#6222)
  • deps-dev: bump testcontainers from 4.9.1 to 4.9.2 (#6225)
  • deps-dev: bump cfn-lint from 1.26.1 to 1.27.0 (#6192)
  • deps-dev: bump boto3-stubs from 1.37.2 to 1.37.3 (#6181)
  • deps-dev: bump isort from 6.0.0 to 6.0.1 (#6183)
  • deps-dev: bump boto3-stubs from 1.37.5 to 1.37.6 (#6227)
  • deps-dev: bump ruff from 0.9.7 to 0.9.8 (#6184)

... (truncated)

Upgrade guide

Sourced from aws-lambda-powertools's upgrade guide.


title: Upgrade guide description: Guide to update between major Powertools for AWS Lambda (Python) versions

Migrate to v3 from v2

!!! info "We strongly encourage you to migrate to v3. However, if you still need to upgrade from v1 to v2, you can find the upgrade guide."

We've made minimal breaking changes to make your transition to v3 as smooth as possible.

Quick summary

Area Change Code change required
Pydantic We have removed support for Pydantic v1 No
Parser We have replaced DynamoDBStreamModel AttributeValue with native Python types Yes
Parser We no longer export Pydantic objects from parser.pydantic. Yes
Lambda layer Lambda layers are now compiled according to the specific Python version and architecture No
Event Handler We have deprecated the get_header_value function. Yes
Batch Processor @batch_processor and @async_batch_processor decorators are now deprecated Yes
Event Source Data Classes We have updated default values for optional fields. Yes
Parameters The default cache TTL is now set to 5 minutes No
Parameters The config parameter is deprecated in favor of boto_config Yes
JMESPath Functions The extract_data_from_envelope function is deprecated in favor of query Yes
Types file We have removed the type imports from the shared/types.py file Yes

First Steps

Before you start, we suggest making a copy of your current working project or create a new branch with git.

  1. Upgrade Python to at least v3.9.
  2. Ensure you have the latest version via Lambda Layer or PyPi{target="_blank"}.
  3. Review the following sections to confirm if you need to make changes to your code.

Drop support for Pydantic v1

!!! note "No code changes required"

As of June 30, 2024, Pydantic v1 has reached its end-of-life, and we have discontinued support for this version. We now exclusively support Pydantic v2.

Use Pydantic v2 Migration Guide{target="_blank"} to migrate your custom Pydantic models to v2.

DynamoDBStreamModel in parser

!!! info "This also applies if you're using DynamoDB BatchProcessor{target="_blank"}."

DynamoDBStreamModel now returns native Python types when you access DynamoDB records through Keys, NewImage, and OldImage attributes.

... (truncated)

Commits
  • 16a866f chore: version bump
  • 9775975 fix(event_handler): revert regression when validating response (#6234)
  • 76b4d8f feat(logger): add logger buffer feature (#6060)
  • 4b84e93 chore(ci): new pre-release 3.7.1a7 (#6233)
  • 5a26c50 chore(deps-dev): bump boto3-stubs from 1.37.6 to 1.37.7 (#6231)
  • baac824 chore(deps-dev): bump aws-cdk from 2.1002.0 to 2.1003.0 (#6232)
  • a5a07c0 chore(ci): changelog rebuild (#6230)
  • 5eba5ed chore(ci): new pre-release 3.7.1a6 (#6229)
  • 9031d3c chore(deps-dev): bump jinja2 from 3.1.5 to 3.1.6 (#6224)
  • 0214bcc chore(deps-dev): bump boto3-stubs from 1.37.5 to 1.37.6 (#6227)
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [aws-lambda-powertools](https://github.com/aws-powertools/powertools-lambda-python) from 2.35.1 to 3.8.0.
- [Release notes](https://github.com/aws-powertools/powertools-lambda-python/releases)
- [Changelog](https://github.com/aws-powertools/powertools-lambda-python/blob/develop/CHANGELOG.md)
- [Upgrade guide](https://github.com/aws-powertools/powertools-lambda-python/blob/develop/docs/upgrade.md)
- [Commits](aws-powertools/powertools-lambda-python@v2.35.1...v3.8.0)

---
updated-dependencies:
- dependency-name: aws-lambda-powertools
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot added dependencies Pull requests that update a dependency file python Pull requests that update Python code labels Mar 10, 2025
@sonarqubecloud
Copy link

@github-actions
Copy link

💥 Something went wrong while building the pull request environment.
Check Output Logs

@dependabot @github
Copy link
Contributor Author

dependabot bot commented on behalf of github Mar 31, 2025

Superseded by #873.

@dependabot dependabot bot closed this Mar 31, 2025
@dependabot dependabot bot deleted the dependabot/pip/aws-lambda-powertools-3.8.0 branch March 31, 2025 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants