# Powertools for AWS Lambda (Java)
> Powertools for AWS Lambda (Java)
Powertools for AWS Lambda (Java) is a developer toolkit to implement Serverless best practices and increase developer velocity. It provides a suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier.
# Project Overview
Powertools for AWS Lambda (Java) is a developer toolkit to implement Serverless best practices and increase developer velocity.
Tip
Powertools for AWS Lambda is also available for [Python](https://docs.powertools.aws.dev/lambda/python/latest/), [TypeScript](https://docs.powertools.aws.dev/lambda/typescript/latest/), and [.NET](https://docs.powertools.aws.dev/lambda/dotnet/)
Looking for a quick run through of the core utilities?
Check out [this detailed blog post](https://aws.amazon.com/blogs/compute/introducing-v2-of-powertools-for-aws-lambda-java/) with a practical example. To dive deeper, the [Powertools for AWS Lambda (Java) workshop](https://catalog.us-east-1.prod.workshops.aws/workshops/a7011c82-e4af-4a52-80fa-fcd61f1dacd9/en-US/introduction) is a great next step.
## Tenets
This project separates core utilities that will be available in other runtimes vs general utilities that might not be available across all runtimes.
- **AWS Lambda only** – We optimise for AWS Lambda function environments and supported runtimes only. Utilities might work with web frameworks and non-Lambda environments, though they are not officially supported.
- **Eases the adoption of best practices** – The main priority of the utilities is to facilitate best practices adoption, as defined in the AWS Well-Architected Serverless Lens; all other functionality is optional.
- **Keep it lean** – Additional dependencies are carefully considered for security and ease of maintenance, and prevent negatively impacting startup time.
- **We strive for backwards compatibility** – New features and changes should keep backwards compatibility. If a breaking change cannot be avoided, the deprecation and migration process should be clearly defined.
- **We work backwards from the community** – We aim to strike a balance of what would work best for 80% of customers. Emerging practices are considered and discussed via Requests for Comment (RFCs)
- **Progressive** - Utilities are designed to be incrementally adoptable for customers at any stage of their Serverless journey. They follow language idioms and their community’s common practices.
## Install
Powertools for AWS Lambda (Java) dependencies are available in Maven Central. You can use your favourite dependency management tool to install it
- [Maven](https://maven.apache.org/)
- [Gradle](https://gradle.org)
```
...
software.amazon.lambdapowertools-tracing2.6.0software.amazon.lambdapowertools-logging-log4j2.6.0software.amazon.lambdapowertools-metrics2.6.0org.aspectjaspectjrt1.9.22
...
...
...
dev.aspectjaspectj-maven-plugin1.14111111software.amazon.lambdapowertools-tracingsoftware.amazon.lambdapowertools-loggingsoftware.amazon.lambdapowertools-metricsorg.aspectjaspectjtools1.9.22compile
...
```
```
plugins {
id 'java'
id 'io.freefair.aspectj.post-compile-weaving' version '8.2.2'
}
// the freefair aspect plugins targets gradle 8.2.1
// https://docs.freefair.io/gradle-plugins/8.2.2/reference/
wrapper {
gradleVersion = "8.2.1"
}
repositories {
mavenCentral()
}
dependencies {
// Note: This AspectJ configuration is not needed when using the functional approach
aspect 'software.amazon.lambda:powertools-logging-log4j:2.6.0'
aspect 'software.amazon.lambda:powertools-tracing:2.6.0'
aspect 'software.amazon.lambda:powertools-metrics:2.6.0'
}
sourceCompatibility = 11
targetCompatibility = 11
```
Don't want to use AspectJ?
Powertools for AWS Lambda (Java) now provides a functional API that doesn't require AspectJ configuration. Learn more about the [functional approach](usage-patterns/#functional-approach).
### Java Compatibility
Powertools for AWS Lambda (Java) supports all Java versions from 11 up to 25 inline with the [corresponding Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html).
In addition to the functional approach, [Logging](core/logging/), [Metrics](core/metrics/), [Tracing](core/tracing/), [Parameters](utilities/parameters/), [Idempotency](utilities/idempotency/), [Validation](utilities/validation/), and [Large Messages](utilities/large_messages/) utilities support annotations using AspectJ, which require configuration of the `aspectjrt` runtime library.
You may need to add the appropriate version of `aspectjrt` to your dependencies based on the JDK used for building your function:
```
org.aspectjaspectjrt1.9.??
```
Use the following [dependency matrix](https://github.com/eclipse-aspectj/aspectj/blob/master/docs/release/JavaVersionCompatibility.adoc) to understand which AspectJ version to use based on your JDK version:
| JDK version | aspectj version | | --- | --- | | `11-17` | `1.9.20.1` (or higher) | | `21` | `1.9.21` (or higher) | | `25` | `1.9.25` (or higher) |
## Environment variables
Info
Explicit parameters take precedence over environment variables.
| Environment variable | Description | Utility | | --- | --- | --- | | **POWERTOOLS_SERVICE_NAME** | Sets service name used for tracing namespace, metrics dimension and structured logging | All | | **POWERTOOLS_METRICS_NAMESPACE** | Sets namespace used for metrics | [Metrics](./core/metrics) | | **POWERTOOLS_METRICS_FUNCTION_NAME** | Function name used as dimension for the cold start metric | [Metrics](./core/metrics) | | **POWERTOOLS_METRICS_DISABLED** | Disables all flushing of metrics | [Metrics](./core/metrics) | | **POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logging) | | **POWERTOOLS_LOG_LEVEL** | Sets logging level | [Logging](./core/logging) | | **POWERTOOLS_LOGGER_LOG_EVENT** | Enables/Disables whether to log the incoming event when using the aspect | [Logging](./core/logging) | | **POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Enables/Disables tracing mode to capture method response | [Tracing](./core/tracing) | | **POWERTOOLS_TRACER_CAPTURE_ERROR** | Enables/Disables tracing mode to capture method error | [Tracing](./core/tracing) |
## How can I use Powertools for AWS Lambda (Java) with Lombok?
Many utilities in this library use `aspectj-maven-plugin` to compile-time weave (CTW) aspects into the project. In case you want to use `Lombok` or other compile-time preprocessor for your project, it is required to change `aspectj-maven-plugin` configuration to enable in-place weaving feature. Otherwise the plugin will ignore changes introduced by `Lombok` and will use `.java` files as a source.
Alternatively, you can use the [functional approach](../usage-patterns/#functional-approach) which does not require AspectJ configuration.
To enable in-place weaving feature you need to use following `aspectj-maven-plugin` configuration:
```
true${project.build.directory}/classes
...
software.amazon.lambdapowertools-logging
```
## How can I use Powertools for AWS Lambda (Java) with Kotlin projects?
Many utilities use `aspectj-maven-plugin` to compile-time weave (CTW) aspects into the project. When using it with Kotlin projects, it is required to `forceAjcCompile`. No explicit configuration should be required for gradle projects.
Alternatively, you can use the [functional approach](../usage-patterns/#functional-approach) which does not require AspectJ configuration.
To enable `forceAjcCompile` you need to use following `aspectj-maven-plugin` configuration:
```
true
...
software.amazon.lambdapowertools-logging
```
## How can I use Powertools for AWS Lambda (Java) with the AWS CRT HTTP Client?
Utilities relying on AWS SDK clients use the `url-connection-client` as the default HTTP client. The `url-connection-client` is a lightweight HTTP client, which keeps the impact on Lambda cold starts to a minimum. With the [announcement](https://aws.amazon.com/blogs/developer/announcing-availability-of-the-aws-crt-http-client-in-the-aws-sdk-for-java-2-x/) of the `aws-crt-client` a new HTTP client has been released, which offers faster SDK startup time and smaller memory footprint.
Unfortunately, replacing the `url-connection-client` dependency with the `aws-crt-client` will not immediately improve the lambda cold start performance and memory footprint, as the default version of the dependency contains native system libraries for all supported runtimes and architectures (Linux, MacOS, Windows, AMD64, ARM64, etc). This makes the CRT client portable, without the user having to consider *where* their code will run, but comes at the cost of JAR size.
### Configuring dependencies
Using the `aws-crt-client` in your project requires the exclusion of the `url-connection-client` transitive dependency from the `powertools-*` dependency.
```
software.amazon.lambdapowertools-parameters2.0.0software.amazon.awssdkurl-connection-client
```
Next, add the `aws-crt-client` and exclude the "generic" `aws-crt` dependency (contains all runtime libraries). Instead, set a specific classifier of the `aws-crt` to use the one for your target runtime: either `linux-x86_64` for a Lambda configured for x86 or `linux-aarch_64` for Lambda using arm64.
You will need to add a separate maven profile to build and debug locally when your development environment does not share the target architecture you are using in Lambda.
By specifying the specific target runtime, we prevent other target runtimes from being included in the jar file, resulting in a smaller Lambda package and improved cold start times.
```
software.amazon.awssdkaws-crt-client2.23.21software.amazon.awssdk.crtaws-crtsoftware.amazon.awssdk.crtaws-crt0.29.9linux-x86_64
```
### Explicitly set the AWS CRT HTTP Client
After configuring the dependencies, it's required to explicitly specify the AWS SDK HTTP client. Depending on the utility you are using, there is a different way to configure the SDK client.
The following example shows how to use the Parameters module while leveraging the AWS CRT Client.
```
import static software.amazon.lambda.powertools.parameters.transform.Transformer.base64;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import software.amazon.awssdk.services.ssm.SsmClient;
import software.amazon.awssdk.http.crt.AwsCrtHttpClient;
import software.amazon.lambda.powertools.parameters.ssm.SSMProvider;
public class RequestHandlerWithParams implements RequestHandler {
// Get an instance of the SSMProvider with a custom HTTP client (aws crt).
SSMProvider ssmProvider = SSMProvider
.builder()
.withClient(
SsmClient.builder()
.httpClient(AwsCrtHttpClient.builder().build())
.build()
)
.build();
public String handleRequest(String input, Context context) {
// Retrieve a single param
String value = ssmProvider
.get("/my/secret");
// We might instead want to retrieve multiple parameters at once, returning a Map of key/value pairs
// .getMultiple("/my/secret/path");
// Return the result
return value;
}
}
```
The `aws-crt-client` was considered for adoption as the default HTTP client in Powertools for AWS Lambda (Java) as mentioned in [Move SDK http client to CRT](https://github.com/aws-powertools/powertools-lambda-java/issues/1092), but due to the impact on the developer experience it was decided to stick with the `url-connection-client`.
## How can I use Powertools for AWS Lambda (Java) with GraalVM?
Core utilities, i.e. [logging](../core/logging/), [metrics](../core/metrics/) and [tracing](../core/tracing/), include the [GraalVM Reachability Metadata (GRM)](https://www.graalvm.org/latest/reference-manual/native-image/metadata/) in the `META-INF` directories of the respective JARs. You can find a working example of Serverless Application Model (SAM) based application in the [examples](../examples/powertools-examples-core-utilities/sam-graalvm/README.md) directory.
Below, you find typical steps you need to follow in a Maven based Java project:
### Set the environment to use GraalVM
```
export JAVA_HOME=
```
### Use log4j `>2.24.0`
Log4j version `2.24.0` adds [support for GraalVM](https://github.com/apache/logging-log4j2/issues/1539#issuecomment-2106766878). Depending on your project's dependency hierarchy, older version of log4j might be included in the final dependency graph. Make sure version `>2.24.0` of these dependencies are used by your Maven project:
```
org.apache.logging.log4jlog4j-api${log4j.version}org.apache.logging.log4jlog4j-core${log4j.version}org.apache.logging.log4jlog4j-slf4j2-impl${log4j.version}org.apache.logging.log4jlog4j-layout-template-json${log4j.version}
```
### Add the AWS Lambda Java Runtime Interface Client dependency
The Runtime Interface Client allows your function to receive invocation events from Lambda, send the response back to Lambda, and report errors to the Lambda service. Add the below dependency to your Maven project:
```
com.amazonawsaws-lambda-java-runtime-interface-client2.1.1
```
Also include the AWS Lambda GRM files by copying the `com.amazonaws` [directory](../examples/powertools-examples-core-utilities/sam-graalvm/src/main/resources/META-INF/native-image/) in your project's `META-INF/native-image` directory
### Build the native image
Use the `native-maven-plugin` to build the native image. You can do this by adding the plugin to your `pom.xml` and creating a build profile called `native-image` that can build the native image of your Lambda function:
```
native-imageorg.graalvm.buildtoolsnative-maven-plugin0.10.1truebuild-nativebuildpackageyour-project-namecom.amazonaws.services.lambda.runtime.api.client.AWSLambda--enable-url-protocols=http--add-opens java.base/java.util=ALL-UNNAMED
```
Create a Docker image using a `Dockerfile` like [this](../examples/powertools-examples-core-utilities/sam-graalvm/Dockerfile) to create an x86 based build image.
```
docker build --platform linux/amd64 . -t your-org/your-app-graalvm-builder
```
Create the native image of you Lambda function using the Docker command below.
```
docker run --platform linux/amd64 -it -v `pwd`:`pwd` -w `pwd` -v ~/.m2:/root/.m2 your-org/your-app-graalvm-builder mvn clean -Pnative-image package
```
The native image is created in the `target/` directory.
# Unreleased
## Documentation
- **logger:** Fix logging environment variables names in documentation ([#2161](https://github.com/aws-powertools/powertools-lambda-java/issues/2161))
## Features
- add CRaC priming support to powertools-kafka module ([#2145](https://github.com/aws-powertools/powertools-lambda-java/issues/2145))
- **metrics:** introduce Metrics.flushMetrics ([#2154](https://github.com/aws-powertools/powertools-lambda-java/issues/2154))
## Maintenance
- bump aws.sdk.version from 2.35.6 to 2.35.7 ([#2190](https://github.com/aws-powertools/powertools-lambda-java/issues/2190))
- bump com.networknt:json-schema-validator from 1.5.8 to 1.5.9 ([#2189](https://github.com/aws-powertools/powertools-lambda-java/issues/2189))
- bump sam/build-java21 ([#2195](https://github.com/aws-powertools/powertools-lambda-java/issues/2195))
- bump squidfunk/mkdocs-material in /docs ([#2194](https://github.com/aws-powertools/powertools-lambda-java/issues/2194))
- bump com.github.spotbugs:spotbugs-maven-plugin ([#2192](https://github.com/aws-powertools/powertools-lambda-java/issues/2192))
- bump software.amazon.awscdk:aws-cdk-lib from 2.214.0 to 2.220.0 ([#2191](https://github.com/aws-powertools/powertools-lambda-java/issues/2191))
- bump io.github.ascopes:protobuf-maven-plugin ([#2193](https://github.com/aws-powertools/powertools-lambda-java/issues/2193))
- bump aws.xray.recorder.version from 2.19.0 to 2.20.0 ([#2185](https://github.com/aws-powertools/powertools-lambda-java/issues/2185))
- bump aws.sdk.version from 2.33.2 to 2.33.5 ([#2132](https://github.com/aws-powertools/powertools-lambda-java/issues/2132))
- bump org.apache.maven.plugins:maven-javadoc-plugin ([#2186](https://github.com/aws-powertools/powertools-lambda-java/issues/2186))
- bump org.assertj:assertj-core from 3.27.4 to 3.27.6 ([#2184](https://github.com/aws-powertools/powertools-lambda-java/issues/2184))
- bump aws.sdk.version from 2.34.9 to 2.35.6 ([#2183](https://github.com/aws-powertools/powertools-lambda-java/issues/2183))
- bump actions/dependency-review-action from 4.8.0 to 4.8.1 ([#2180](https://github.com/aws-powertools/powertools-lambda-java/issues/2180))
- bump github/codeql-action from 3.30.5 to 4.30.8 ([#2179](https://github.com/aws-powertools/powertools-lambda-java/issues/2179))
- bump aws-actions/configure-aws-credentials from 5.0.0 to 5.1.0 ([#2177](https://github.com/aws-powertools/powertools-lambda-java/issues/2177))
- bump com.google.protobuf:protobuf-java from 4.32.0 to 4.32.1 ([#2175](https://github.com/aws-powertools/powertools-lambda-java/issues/2175))
- bump aws.sdk.version from 2.34.5 to 2.34.9 ([#2174](https://github.com/aws-powertools/powertools-lambda-java/issues/2174))
- bump org.apache.commons:commons-lang3 from 3.18.0 to 3.19.0 ([#2172](https://github.com/aws-powertools/powertools-lambda-java/issues/2172))
- bump org.apache.maven.plugins:maven-artifact-plugin ([#2171](https://github.com/aws-powertools/powertools-lambda-java/issues/2171))
- Add User-Agent execution interceptors ([#2166](https://github.com/aws-powertools/powertools-lambda-java/issues/2166))
- bump org.apache.kafka:kafka-clients from 4.0.0 to 4.1.0 ([#2134](https://github.com/aws-powertools/powertools-lambda-java/issues/2134))
- bump graalvm/setup-graalvm from 1.3.6 to 1.4.1 ([#2168](https://github.com/aws-powertools/powertools-lambda-java/issues/2168))
- bump ossf/scorecard-action from 2.4.2 to 2.4.3 ([#2165](https://github.com/aws-powertools/powertools-lambda-java/issues/2165))
- bump squidfunk/mkdocs-material in /docs ([#2164](https://github.com/aws-powertools/powertools-lambda-java/issues/2164))
- bump log4j.version from 2.25.1 to 2.25.2 ([#2160](https://github.com/aws-powertools/powertools-lambda-java/issues/2160))
- bump org.apache.maven.plugins:maven-failsafe-plugin ([#2159](https://github.com/aws-powertools/powertools-lambda-java/issues/2159))
- bump actions/dependency-review-action from 4.7.3 to 4.8.0 ([#2158](https://github.com/aws-powertools/powertools-lambda-java/issues/2158))
- bump github/codeql-action from 3.30.1 to 3.30.5 ([#2157](https://github.com/aws-powertools/powertools-lambda-java/issues/2157))
- bump io.github.ascopes:protobuf-maven-plugin from 3.9.0 to 3.10.0 ([#2155](https://github.com/aws-powertools/powertools-lambda-java/issues/2155))
- bump com.amazonaws:aws-lambda-java-runtime-interface-client ([#2149](https://github.com/aws-powertools/powertools-lambda-java/issues/2149))
- bump aws.sdk.version from 2.33.2 to 2.34.5 ([#2156](https://github.com/aws-powertools/powertools-lambda-java/issues/2156))
- bump org.codehaus.mojo:versions-maven-plugin ([#2148](https://github.com/aws-powertools/powertools-lambda-java/issues/2148))
- bump squidfunk/mkdocs-material in /docs ([#2144](https://github.com/aws-powertools/powertools-lambda-java/issues/2144))
- bump tj-actions/changed-files from 46.0.5 to 47.0.0 ([#2143](https://github.com/aws-powertools/powertools-lambda-java/issues/2143))
- bump sam/build-java21 ([#2141](https://github.com/aws-powertools/powertools-lambda-java/issues/2141))
- bump com.amazonaws:aws-lambda-java-core from 1.3.0 to 1.4.0 ([#2135](https://github.com/aws-powertools/powertools-lambda-java/issues/2135))
- **deps:** Use mockito 5.20.0 ([#2181](https://github.com/aws-powertools/powertools-lambda-java/issues/2181))
- **docs:** Add AWS docs meta tags ([#2170](https://github.com/aws-powertools/powertools-lambda-java/issues/2170))
## [v2.4.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v2.3.0...v2.4.0) - 2025-09-09
## Bug Fixes
- **ci:** Update branch protection output ([#2053](https://github.com/aws-powertools/powertools-lambda-java/issues/2053))
## Documentation
- Add AWS copyright footer. ([#2119](https://github.com/aws-powertools/powertools-lambda-java/issues/2119))
- Update docs introduction
- Rename wrong POWERTOOLS_DISABLE_METRICS to correct POWERTOOLS_METRICS_DISABLED environment variable. ([#2043](https://github.com/aws-powertools/powertools-lambda-java/issues/2043))
- update readme ([#2045](https://github.com/aws-powertools/powertools-lambda-java/issues/2045))
## Features
- Support CRaC priming of powertools validation ([#2081](https://github.com/aws-powertools/powertools-lambda-java/issues/2081))
- **graalvm:** GraalVM support for powertools-cloudformation ([#2090](https://github.com/aws-powertools/powertools-lambda-java/issues/2090))
- **graalvm:** GraalVM support for Idempotency utility ([#2080](https://github.com/aws-powertools/powertools-lambda-java/issues/2080))
- **logging:** Log buffering support for Logj42 and Logback ([#2103](https://github.com/aws-powertools/powertools-lambda-java/issues/2103))
## Maintenance
- bump dev.aspectj:aspectj-maven-plugin from 1.13.1 to 1.14.1 ([#2099](https://github.com/aws-powertools/powertools-lambda-java/issues/2099))
- bump dev.aspectj:aspectj-maven-plugin from 1.14 to 1.14.1 ([#2037](https://github.com/aws-powertools/powertools-lambda-java/issues/2037))
- bump github/codeql-action from 3.29.8 to 3.29.9 ([#2038](https://github.com/aws-powertools/powertools-lambda-java/issues/2038))
- bump org.apache.maven.plugins:maven-deploy-plugin ([#2040](https://github.com/aws-powertools/powertools-lambda-java/issues/2040))
- bump org.yaml:snakeyaml from 2.4 to 2.5 ([#2111](https://github.com/aws-powertools/powertools-lambda-java/issues/2111))
- bump io.github.ascopes:protobuf-maven-plugin from 3.8.1 to 3.9.0 ([#2114](https://github.com/aws-powertools/powertools-lambda-java/issues/2114))
- bump aws.sdk.version from 2.32.31 to 2.33.1 ([#2115](https://github.com/aws-powertools/powertools-lambda-java/issues/2115))
- bump graalvm/setup-graalvm from 1.3.5 to 1.3.6 ([#2116](https://github.com/aws-powertools/powertools-lambda-java/issues/2116))
- bump software.amazon.awscdk:aws-cdk-lib from 2.213.0 to 2.214.0 ([#2117](https://github.com/aws-powertools/powertools-lambda-java/issues/2117))
- bump aws-actions/configure-aws-credentials from 4.3.1 to 5.0.0 ([#2120](https://github.com/aws-powertools/powertools-lambda-java/issues/2120))
- bump com.github.spotbugs:spotbugs-maven-plugin ([#2125](https://github.com/aws-powertools/powertools-lambda-java/issues/2125))
- bump github/codeql-action from 3.30.0 to 3.30.1 ([#2126](https://github.com/aws-powertools/powertools-lambda-java/issues/2126))
- bump squidfunk/mkdocs-material in /docs ([#2127](https://github.com/aws-powertools/powertools-lambda-java/issues/2127))
- bump jackson.version from 2.19.2 to 2.20 ([#2097](https://github.com/aws-powertools/powertools-lambda-java/issues/2097))
- bump aws.sdk.version from 2.32.18 to 2.32.21 ([#2041](https://github.com/aws-powertools/powertools-lambda-java/issues/2041))
- bump aws.sdk.version from 2.32.26 to 2.32.31 ([#2098](https://github.com/aws-powertools/powertools-lambda-java/issues/2098))
- bump github/codeql-action from 3.29.11 to 3.30.0 ([#2106](https://github.com/aws-powertools/powertools-lambda-java/issues/2106))
- bump software.amazon.awscdk:aws-cdk-lib from 2.212.0 to 2.213.0 ([#2100](https://github.com/aws-powertools/powertools-lambda-java/issues/2100))
- bump org.apache.maven.plugins:maven-compiler-plugin ([#2094](https://github.com/aws-powertools/powertools-lambda-java/issues/2094))
- bump actions/checkout from 4.2.2 to 5.0.0 ([#2087](https://github.com/aws-powertools/powertools-lambda-java/issues/2087))
- bump org.apache.logging.log4j:log4j-transform-maven-shade-plugin-extensions ([#2088](https://github.com/aws-powertools/powertools-lambda-java/issues/2088))
- bump io.github.ascopes:protobuf-maven-plugin from 3.8.0 to 3.8.1 ([#2085](https://github.com/aws-powertools/powertools-lambda-java/issues/2085))
- bump com.github.spotbugs:spotbugs-maven-plugin ([#2084](https://github.com/aws-powertools/powertools-lambda-java/issues/2084))
- bump sam/build-java21 ([#2083](https://github.com/aws-powertools/powertools-lambda-java/issues/2083))
- bump aws.sdk.version from 2.32.30 to 2.32.31 ([#2093](https://github.com/aws-powertools/powertools-lambda-java/issues/2093))
- bump actions/dependency-review-action from 4.7.2 to 4.7.3 ([#2092](https://github.com/aws-powertools/powertools-lambda-java/issues/2092))
- bump aws.sdk.version from 2.32.28 to 2.32.30 ([#2089](https://github.com/aws-powertools/powertools-lambda-java/issues/2089))
- bump software.amazon.awscdk:aws-cdk-lib from 2.210.0 to 2.211.0 ([#2042](https://github.com/aws-powertools/powertools-lambda-java/issues/2042))
- bump aws.sdk.version from 2.32.21 to 2.32.22 ([#2046](https://github.com/aws-powertools/powertools-lambda-java/issues/2046))
- bump com.google.protobuf:protobuf-java from 4.31.1 to 4.32.0 ([#2050](https://github.com/aws-powertools/powertools-lambda-java/issues/2050))
- bump aws.sdk.version from 2.32.23 to 2.32.25 ([#2054](https://github.com/aws-powertools/powertools-lambda-java/issues/2054))
- bump squidfunk/mkdocs-material in /docs ([#2074](https://github.com/aws-powertools/powertools-lambda-java/issues/2074))
- bump github/codeql-action from 3.29.10 to 3.29.11 ([#2073](https://github.com/aws-powertools/powertools-lambda-java/issues/2073))
- bump log4j.version from 2.25.1 to 2.25.1 ([#2072](https://github.com/aws-powertools/powertools-lambda-java/issues/2072))
- bump org.apache.maven.plugins:maven-shade-plugin ([#2071](https://github.com/aws-powertools/powertools-lambda-java/issues/2071))
- bump org.graalvm.buildtools:native-maven-plugin ([#2070](https://github.com/aws-powertools/powertools-lambda-java/issues/2070))
- bump com.amazonaws:aws-lambda-java-runtime-interface-client ([#2069](https://github.com/aws-powertools/powertools-lambda-java/issues/2069))
- bump aws.sdk.version from 2.32.2 to 2.32.28 ([#2068](https://github.com/aws-powertools/powertools-lambda-java/issues/2068))
- bump actions/setup-java from 4.7.1 to 5.0.0 ([#2067](https://github.com/aws-powertools/powertools-lambda-java/issues/2067))
- bump software.amazon.awscdk:aws-cdk-lib from 2.211.0 to 2.212.0 ([#2066](https://github.com/aws-powertools/powertools-lambda-java/issues/2066))
- bump org.apache.maven.plugins:maven-javadoc-plugin ([#2065](https://github.com/aws-powertools/powertools-lambda-java/issues/2065))
- bump aws.sdk.version from 2.32.25 to 2.32.27 ([#2064](https://github.com/aws-powertools/powertools-lambda-java/issues/2064))
- bump aws.sdk.version from 2.32.22 to 2.32.23 ([#2048](https://github.com/aws-powertools/powertools-lambda-java/issues/2048))
- bump squidfunk/mkdocs-material in /docs ([#2058](https://github.com/aws-powertools/powertools-lambda-java/issues/2058))
- bump org.apache.maven.plugins:maven-javadoc-plugin ([#2059](https://github.com/aws-powertools/powertools-lambda-java/issues/2059))
- bump io.github.ascopes:protobuf-maven-plugin from 3.7.0 to 3.8.0 ([#2057](https://github.com/aws-powertools/powertools-lambda-java/issues/2057))
- bump actions/checkout from 4.2.2 to 5.0.0 ([#2036](https://github.com/aws-powertools/powertools-lambda-java/issues/2036))
- bump actions/dependency-review-action from 4.7.1 to 4.7.2 ([#2055](https://github.com/aws-powertools/powertools-lambda-java/issues/2055))
- bump sam/build-java21 ([#2075](https://github.com/aws-powertools/powertools-lambda-java/issues/2075))
- bump aws.sdk.version from 2.32.19 to 2.32.26 ([#2060](https://github.com/aws-powertools/powertools-lambda-java/issues/2060))
- bump github/codeql-action from 3.29.9 to 3.29.10 ([#2056](https://github.com/aws-powertools/powertools-lambda-java/issues/2056))
- **ci:** Add powertools-e2e-tests/handlers as module to capture it in GitHub actions version upgrades. ([#2063](https://github.com/aws-powertools/powertools-lambda-java/issues/2063))
- **ci:** Fix bug where docs were released with old version during release workflow. ([#2076](https://github.com/aws-powertools/powertools-lambda-java/issues/2076))
- **ci:** Run unit tests for GraalVM as well during build. ([#2047](https://github.com/aws-powertools/powertools-lambda-java/issues/2047))
- **ci:** Remove non-PR triggers for verify dependencies workflow. ([#2044](https://github.com/aws-powertools/powertools-lambda-java/issues/2044))
- **ci:** Fix circular dependency in dynamodb-local and maven packaging phases. ([#2129](https://github.com/aws-powertools/powertools-lambda-java/issues/2129))
- **ci:** Do not use Mockito SNAPSHOT version for release. ([#2137](https://github.com/aws-powertools/powertools-lambda-java/issues/2137))
- **ci:** Set mockito SNAPSHOT version only for Graal profiles. ([#2138](https://github.com/aws-powertools/powertools-lambda-java/issues/2138))
- **gitignore:** add .kiro, .claude, .amazonq to prevent deletion ([#2078](https://github.com/aws-powertools/powertools-lambda-java/issues/2078))
## [v2.3.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v2.2.1...v2.3.0) - 2025-08-12
## Documentation
- **examples:** Add Bazel example for core utilities ([#2022](https://github.com/aws-powertools/powertools-lambda-java/issues/2022))
- **examples:** Add Logging and Tracing to idempotency example with correct configuration. ([#1993](https://github.com/aws-powertools/powertools-lambda-java/issues/1993))
- **examples:** Enable end to end tracing for SQS batch example. ([#1995](https://github.com/aws-powertools/powertools-lambda-java/issues/1995))
## Features
- Support CRaC priming of powertools metrics and idempotency-dynamodb ([#1861](https://github.com/aws-powertools/powertools-lambda-java/issues/1861))
## Maintenance
- bump github/codeql-action from 3.29.4 to 3.29.5 ([#1992](https://github.com/aws-powertools/powertools-lambda-java/issues/1992))
- bump org.assertj:assertj-core from 3.27.3 to 3.27.4 ([#2031](https://github.com/aws-powertools/powertools-lambda-java/issues/2031))
- bump software.amazon.awscdk:aws-cdk-lib from 2.208.0 to 2.210.0 ([#2030](https://github.com/aws-powertools/powertools-lambda-java/issues/2030))
- bump aws.sdk.version from 2.32.18 to 2.32.19 ([#2029](https://github.com/aws-powertools/powertools-lambda-java/issues/2029))
- bump co.elastic.logging:logback-ecs-encoder from 1.6.0 to 1.7.0 ([#2028](https://github.com/aws-powertools/powertools-lambda-java/issues/2028))
- bump com.github.spotbugs:spotbugs-maven-plugin from 4.8.4.0 to 4.9.3.2 ([#2010](https://github.com/aws-powertools/powertools-lambda-java/issues/2010))
- bump com.amazonaws:aws-lambda-java-runtime-interface-client ([#2026](https://github.com/aws-powertools/powertools-lambda-java/issues/2026))
- bump github/codeql-action from 3.29.7 to 3.29.8 ([#2027](https://github.com/aws-powertools/powertools-lambda-java/issues/2027))
- bump org.crac:crac from 1.4.0 to 1.5.0 ([#2025](https://github.com/aws-powertools/powertools-lambda-java/issues/2025))
- bump aws.sdk.version from 2.32.6 to 2.32.18 ([#2024](https://github.com/aws-powertools/powertools-lambda-java/issues/2024))
- bump org.junit.jupiter:junit-jupiter from 5.11.1 to 5.13.4 ([#2023](https://github.com/aws-powertools/powertools-lambda-java/issues/2023))
- bump org.codehaus.mojo:exec-maven-plugin from 3.3.0 to 3.5.1 ([#2015](https://github.com/aws-powertools/powertools-lambda-java/issues/2015))
- bump aws.sdk.version from 2.32.10 to 2.32.16 ([#2014](https://github.com/aws-powertools/powertools-lambda-java/issues/2014))
- bump io.github.ascopes:protobuf-maven-plugin from 3.6.1 to 3.7.0 ([#2016](https://github.com/aws-powertools/powertools-lambda-java/issues/2016))
- bump actions/download-artifact from 4.3.0 to 5.0.0 ([#2017](https://github.com/aws-powertools/powertools-lambda-java/issues/2017))
- bump squidfunk/mkdocs-material in /docs ([#1984](https://github.com/aws-powertools/powertools-lambda-java/issues/1984))
- bump org.apache.maven.plugins:maven-surefire-plugin ([#2013](https://github.com/aws-powertools/powertools-lambda-java/issues/2013))
- bump aws-actions/configure-aws-credentials from 4.2.1 to 4.3.1 ([#2011](https://github.com/aws-powertools/powertools-lambda-java/issues/2011))
- bump software.amazon.awscdk:aws-cdk-lib from 2.162.1 to 2.208.0 ([#1990](https://github.com/aws-powertools/powertools-lambda-java/issues/1990))
- **ci:** Make E2E tests compatible with latest CDK lib version. Improve retry implementation. ([#2008](https://github.com/aws-powertools/powertools-lambda-java/issues/2008))
- **ci:** Improve reliability of retries in TracingE2ET ([#2018](https://github.com/aws-powertools/powertools-lambda-java/issues/2018))
## [v2.2.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v2.2.0...v2.2.1) - 2025-07-29
## Bug Fixes
- **parameters:** Correctly check for empty values in AppConfig Parameters Provider. ([#1982](https://github.com/aws-powertools/powertools-lambda-java/issues/1982))
## Maintenance
- bump dependabot/fetch-metadata from 2.3.0 to 2.4.0 ([#1954](https://github.com/aws-powertools/powertools-lambda-java/issues/1954))
- bump github/codeql-action from 3.29.3 to 3.29.4 ([#1978](https://github.com/aws-powertools/powertools-lambda-java/issues/1978))
- bump org.apache.logging.log4j:log4j-transform-maven-shade-plugin-extensions ([#1977](https://github.com/aws-powertools/powertools-lambda-java/issues/1977))
- bump aws.sdk.version from 2.31.78 to 2.32.6 ([#1976](https://github.com/aws-powertools/powertools-lambda-java/issues/1976))
- bump com.amazonaws:aws-lambda-java-events from 3.16.0 to 3.16.1 ([#1975](https://github.com/aws-powertools/powertools-lambda-java/issues/1975))
- bump com.networknt:json-schema-validator from 1.5.1 to 1.5.8 ([#1974](https://github.com/aws-powertools/powertools-lambda-java/issues/1974))
- bump ossf/scorecard-action from 2.4.0 to 2.4.2 ([#1950](https://github.com/aws-powertools/powertools-lambda-java/issues/1950))
- bump org.apache.maven.plugins:maven-compiler-plugin ([#1972](https://github.com/aws-powertools/powertools-lambda-java/issues/1972))
- bump actions/download-artifact from 4.2.1 to 4.3.0 ([#1967](https://github.com/aws-powertools/powertools-lambda-java/issues/1967))
- bump aws-actions/configure-aws-credentials from 2.2.0 to 4.2.1 ([#1965](https://github.com/aws-powertools/powertools-lambda-java/issues/1965))
- bump actions/dependency-review-action from 4.5.0 to 4.7.1 ([#1968](https://github.com/aws-powertools/powertools-lambda-java/issues/1968))
- bump actions/checkout from 3.5.3 to 4.2.2 ([#1963](https://github.com/aws-powertools/powertools-lambda-java/issues/1963))
- bump sam/build-java21 ([#1962](https://github.com/aws-powertools/powertools-lambda-java/issues/1962))
- bump squidfunk/mkdocs-material in /docs ([#1961](https://github.com/aws-powertools/powertools-lambda-java/issues/1961))
- bump actions/upload-artifact from 4.5.0 to 4.6.2 ([#1953](https://github.com/aws-powertools/powertools-lambda-java/issues/1953))
- bump github/codeql-action from 3.27.9 to 3.29.3 ([#1958](https://github.com/aws-powertools/powertools-lambda-java/issues/1958))
- bump actions/setup-java from 3.11.0 to 4.7.1 ([#1957](https://github.com/aws-powertools/powertools-lambda-java/issues/1957))
- **ci:** Add Docker paths via globs to dependabot and update Dockerfiles to pin sha256 ([#1960](https://github.com/aws-powertools/powertools-lambda-java/issues/1960))
- **ci:** Remove osv workflow. ([#1973](https://github.com/aws-powertools/powertools-lambda-java/issues/1973))
- **ci:** add new dependabot package ecosystems ([#1948](https://github.com/aws-powertools/powertools-lambda-java/issues/1948))
- **ci:** Add GraalVM E2E tests and GH workflows ([#1945](https://github.com/aws-powertools/powertools-lambda-java/issues/1945))
## [v2.2.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v2.1.1...v2.2.0) - 2025-07-15
## Bug Fixes
- **examples:** Fix GraalVM metadata after common runtime client changes ([#1935](https://github.com/aws-powertools/powertools-lambda-java/issues/1935))
## Features
- **batch:** add support for batch execution in parallel with custom Executor ([#1900](https://github.com/aws-powertools/powertools-lambda-java/issues/1900))
- **serialization:** Add GraalVM metadata configuration ([#1905](https://github.com/aws-powertools/powertools-lambda-java/issues/1905))
## Maintenance
- update issue, PR, and discussion templates ([#1915](https://github.com/aws-powertools/powertools-lambda-java/issues/1915))
- **ci:** remove v2 dependabot configuration. Restore OSSF scorecard workflow. ([#1924](https://github.com/aws-powertools/powertools-lambda-java/issues/1924))
- **ci:** Update branch protection rules ([#1914](https://github.com/aws-powertools/powertools-lambda-java/issues/1914))
## [v2.1.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v2.1.0...v2.1.1) - 2025-06-20
## Bug Fixes
- **kafka:** Handle message indices in proto data also for Glue Schema Registry ([#1907](https://github.com/aws-powertools/powertools-lambda-java/issues/1907))
## Maintenance
## [v2.1.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v2.0.0...v2.1.0) - 2025-06-19
## Bug Fixes
- **ci:** Add maven project description to Kafka utility. ([#1903](https://github.com/aws-powertools/powertools-lambda-java/issues/1903))
- **kafka:** Add support for confluent message indices. ([#1902](https://github.com/aws-powertools/powertools-lambda-java/issues/1902))
- **metrics:** Do not flush when no metrics were added to avoid printing root-level \_aws dict ([#1891](https://github.com/aws-powertools/powertools-lambda-java/issues/1891))
## Documentation
- Announce deprecation of v1
- Version documentation ([#1878](https://github.com/aws-powertools/powertools-lambda-java/issues/1878))
## Features
- **kafka:** New Kafka utility ([#1898](https://github.com/aws-powertools/powertools-lambda-java/issues/1898))
## Maintenance
- **ci:** Update workflows to make v2 the default ([#1888](https://github.com/aws-powertools/powertools-lambda-java/issues/1888))
## [v2.0.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v2.0.0-RC1...v2.0.0) - 2025-06-12
## Maintenance
## [v2.0.0-RC1](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.20.2...v2.0.0-RC1) - 2025-06-11
## Bug Fixes
- workflow paths for examples v2 builds
- add aspectj-rt to batch e2e ([#1410](https://github.com/aws-powertools/powertools-lambda-java/issues/1410))
- **ci:** Fix failing E2E tests and temporarily exclude TracingE2E ([#1847](https://github.com/aws-powertools/powertools-lambda-java/issues/1847))
- **ci:** add user/pass to javasetup ([#1832](https://github.com/aws-powertools/powertools-lambda-java/issues/1832))
- **ci:** Update control flow to allow for better skipping of things ([#1831](https://github.com/aws-powertools/powertools-lambda-java/issues/1831))
- **ci:** Checkout repo on doc release ([#1869](https://github.com/aws-powertools/powertools-lambda-java/issues/1869))
- **logging:** Prevent accidental overwriting of reserved keys via structured arguments
- **logging:** Escape double-quotes when serializing strings into JSON. ([#1845](https://github.com/aws-powertools/powertools-lambda-java/issues/1845))
- **v2:** Fix params builder to provide default transformation manager ([#1549](https://github.com/aws-powertools/powertools-lambda-java/issues/1549))
## Documentation
- v2 documentation maintenance fixing formatting and dependency issues as well as adding roadmap and llms.txt ([#1819](https://github.com/aws-powertools/powertools-lambda-java/issues/1819))
- **metrics:** Add upgrade guide for re-designed Metrics utility ([#1868](https://github.com/aws-powertools/powertools-lambda-java/issues/1868))
- **v2:** Create upgrade guide and versioning policy ([#1856](https://github.com/aws-powertools/powertools-lambda-java/issues/1856))
## Features
- advanced logging ([#1539](https://github.com/aws-powertools/powertools-lambda-java/issues/1539))
- upgraded embedded metrics library for high resolution metrics ([#1550](https://github.com/aws-powertools/powertools-lambda-java/issues/1550))
- **cfn-custom-resource:** Add optional 'reason' field for detailed failure reporting ([#1810](https://github.com/aws-powertools/powertools-lambda-java/issues/1810))
- **idempotency:** Add support for ReturnValuesOnConditionCheckFailure in Idempotency. ([#1821](https://github.com/aws-powertools/powertools-lambda-java/issues/1821))
- **idempotency:** Add response hook feature ([#1814](https://github.com/aws-powertools/powertools-lambda-java/issues/1814))
- **metrics:** New metrics module implementation with support for Metrics providers and usage without annotations ([#1863](https://github.com/aws-powertools/powertools-lambda-java/issues/1863))
- **v2:** Add GraalVM reachability metadata for core utilities ([#1753](https://github.com/aws-powertools/powertools-lambda-java/issues/1753))
- **v2:** parallel batch processing ([#1620](https://github.com/aws-powertools/powertools-lambda-java/issues/1620))
- **v2:** batch validation with partial failure ([#1621](https://github.com/aws-powertools/powertools-lambda-java/issues/1621))
- **v2:** publish snapshots ([#1655](https://github.com/aws-powertools/powertools-lambda-java/issues/1655))
- **v2:** GraalVM support for parameters module ([#1824](https://github.com/aws-powertools/powertools-lambda-java/issues/1824))
- **v2:** new logging module ([#1435](https://github.com/aws-powertools/powertools-lambda-java/issues/1435))
- **v2:** Validation failures return 400s ([#1489](https://github.com/aws-powertools/powertools-lambda-java/issues/1489))
## Maintenance
- Support spotbugs running anywhere ([#1537](https://github.com/aws-powertools/powertools-lambda-java/issues/1537))
- V2 update from main ([#1365](https://github.com/aws-powertools/powertools-lambda-java/issues/1365))
- remove Java 8 from v2 examples ([#1531](https://github.com/aws-powertools/powertools-lambda-java/issues/1531))
- fix end 2 end build ([#1534](https://github.com/aws-powertools/powertools-lambda-java/issues/1534))
- cleanup poms and reduce warning noise ([#1535](https://github.com/aws-powertools/powertools-lambda-java/issues/1535))
- [V2] rename 'core' module to 'common' ([#1364](https://github.com/aws-powertools/powertools-lambda-java/issues/1364))
- update v2 ([#1409](https://github.com/aws-powertools/powertools-lambda-java/issues/1409))
- remove aspectj-rt from the library ([#1408](https://github.com/aws-powertools/powertools-lambda-java/issues/1408))
- Start V2 branch ([#1346](https://github.com/aws-powertools/powertools-lambda-java/issues/1346))
- **automation:** Update automation workflows ([#1779](https://github.com/aws-powertools/powertools-lambda-java/issues/1779)) ([#1830](https://github.com/aws-powertools/powertools-lambda-java/issues/1830))
- **ci:** Set snapshot repository to "central" server ID
- **ci:** Publish to Maven Central instead of OSSRH instance ([#1858](https://github.com/aws-powertools/powertools-lambda-java/issues/1858))
- **v2:** Merge down from main ([#1574](https://github.com/aws-powertools/powertools-lambda-java/issues/1574))
- **v2:** Split parameters module up by parameter provider ([#1403](https://github.com/aws-powertools/powertools-lambda-java/issues/1403))
- **v2:** Fix IaC lint ([#1576](https://github.com/aws-powertools/powertools-lambda-java/issues/1576))
- **v2:** e2e tests ([#1571](https://github.com/aws-powertools/powertools-lambda-java/issues/1571))
- **v2:** clean examples ([#1495](https://github.com/aws-powertools/powertools-lambda-java/issues/1495))
- **v2:** document use of aws-crt-client ([#1092](https://github.com/aws-powertools/powertools-lambda-java/issues/1092)) ([#1605](https://github.com/aws-powertools/powertools-lambda-java/issues/1605))
- **v2:** remove java 1.8 relics from the code ([#1659](https://github.com/aws-powertools/powertools-lambda-java/issues/1659))
- **v2:** remove deprecated code ([#1624](https://github.com/aws-powertools/powertools-lambda-java/issues/1624))
- **v2:** Remove rule preventing production release of 2.0.0 ([#1867](https://github.com/aws-powertools/powertools-lambda-java/issues/1867))
- **v2:** Split powertools idempotency module (without redis impl) ([#1559](https://github.com/aws-powertools/powertools-lambda-java/issues/1559))
## Pull Requests
- Merge pull request [#1608](https://github.com/aws-powertools/powertools-lambda-java/issues/1608) from aws-powertools/chore/v2-merge-main-down
- Merge pull request [#1525](https://github.com/aws-powertools/powertools-lambda-java/issues/1525) from aws-powertools/chore/main-into-v2
- Merge pull request [#1494](https://github.com/aws-powertools/powertools-lambda-java/issues/1494) from aws-powertools/chore/merge-main-into-v2
- Merge pull request [#1492](https://github.com/aws-powertools/powertools-lambda-java/issues/1492) from aws-powertools/main-into-v2-again
- Merge pull request [#1477](https://github.com/aws-powertools/powertools-lambda-java/issues/1477) from aws-powertools/chore/main-into-v2
## [v1.20.2](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.20.1...v1.20.2) - 2025-05-20
## Bug Fixes
- **ci:** update release workflow ([#1854](https://github.com/aws-powertools/powertools-lambda-java/issues/1854))
- **ci:** minor fixes for workflows ([#1829](https://github.com/aws-powertools/powertools-lambda-java/issues/1829))
## Documentation
- Add version policy page and llms.txt, enable privacy plugin, fix formatting ([#1823](https://github.com/aws-powertools/powertools-lambda-java/issues/1823))
## Maintenance
- **automation:** Update automation workflows ([#1779](https://github.com/aws-powertools/powertools-lambda-java/issues/1779))
## [v1.20.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.20.0...v1.20.1) - 2025-04-08
## Bug Fixes
- Load version.properties file as resource stream to fix loading when packaged as jar. ([#1813](https://github.com/aws-powertools/powertools-lambda-java/issues/1813))
## Documentation
- fix 2 typos
- Correct XML formatting for Maven configuration in Large Messages utility docs
## Maintenance
- Prep release 1.20.1 ([#1817](https://github.com/aws-powertools/powertools-lambda-java/issues/1817))
## [v1.20.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.19.0...v1.20.0) - 2025-03-25
## Features
- **cfn-custom-resource:** Add optional 'reason' field for detailed failure reporting ([#1758](https://github.com/aws-powertools/powertools-lambda-java/issues/1758))
## Maintenance
- Prep release 1.20.0 ([#1811](https://github.com/aws-powertools/powertools-lambda-java/issues/1811))
## [v1.19.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.18.0...v1.19.0) - 2025-03-07
## Bug Fixes
- add workflow dispatch to OSV
- Allow empty responses as well as null response in AppConfig ([#1673](https://github.com/aws-powertools/powertools-lambda-java/issues/1673))
- **ci:** Add workflow_dispatch to build script ([#1792](https://github.com/aws-powertools/powertools-lambda-java/issues/1792))
- **ci:** add permissions to release workflow
- **ci:** Permissions ([#1771](https://github.com/aws-powertools/powertools-lambda-java/issues/1771))
- **ci:** OSSF Changes ([#1769](https://github.com/aws-powertools/powertools-lambda-java/issues/1769))
## Documentation
- add roadmap page and include roadmap for 2025
- improve tracing doc for sdk instrumentation ([#1687](https://github.com/aws-powertools/powertools-lambda-java/issues/1687))
- add link to Powertools for AWS Lambda workshop ([#1641](https://github.com/aws-powertools/powertools-lambda-java/issues/1641))
- HelloWorldStreamFunction in examples fails with sam ([#1532](https://github.com/aws-powertools/powertools-lambda-java/issues/1532))
## Features
- **build:** remove java 8 support in v2 ([#1606](https://github.com/aws-powertools/powertools-lambda-java/issues/1606))
- **ci:** Add OSV
## Maintenance
- deprecate java1.8 al1 ([#1706](https://github.com/aws-powertools/powertools-lambda-java/issues/1706))
- Testing java21 aspectj pre-release ([#1519](https://github.com/aws-powertools/powertools-lambda-java/issues/1519))
- Remove build cruft
- SAM and Terraform IaC extracted from pr_build and simplified approach. ([#1533](https://github.com/aws-powertools/powertools-lambda-java/issues/1533))
- Update netty version ([#1768](https://github.com/aws-powertools/powertools-lambda-java/issues/1768))
- Set versions of transitive dependencies ([#1767](https://github.com/aws-powertools/powertools-lambda-java/issues/1767))
- update Jackson
- Remove empty CDK test ([#1542](https://github.com/aws-powertools/powertools-lambda-java/issues/1542))
- add openssf to repo
- remove auto-merge
- remove unecessary creds acquisition ([#1572](https://github.com/aws-powertools/powertools-lambda-java/issues/1572))
- update version to next snapshot: 1-19.0-SNAPSHOT ([#1516](https://github.com/aws-powertools/powertools-lambda-java/issues/1516))
- **ci:** update permissions ([#1764](https://github.com/aws-powertools/powertools-lambda-java/issues/1764))
- **ci:** Add release environment
- **ci:** Remove RELEASE variable ([#1772](https://github.com/aws-powertools/powertools-lambda-java/issues/1772))
- **deps:** update JSII to 1.108 ([#1791](https://github.com/aws-powertools/powertools-lambda-java/issues/1791))
- **deps:** Update deps for jackson ([#1793](https://github.com/aws-powertools/powertools-lambda-java/issues/1793))
- **docs:** load self hosted mermaid.js
## Pull Requests
- Merge pull request [#1720](https://github.com/aws-powertools/powertools-lambda-java/issues/1720) from aws-powertools/chore/docs_script_self
## [v1.18.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.17.0...v1.18.0) - 2023-11-16
## Bug Fixes
- get trace id from system property when env var is not set ([#1503](https://github.com/aws-powertools/powertools-lambda-java/issues/1503))
- Fix schema validation unit test build issues ([#1456](https://github.com/aws-powertools/powertools-lambda-java/issues/1456))
## Documentation
- Update gradle configuration readme ([#1359](https://github.com/aws-powertools/powertools-lambda-java/issues/1359))
- Adding Kotlin example. ([#1454](https://github.com/aws-powertools/powertools-lambda-java/issues/1454))
- apply line highlight only for default light mode ([#1453](https://github.com/aws-powertools/powertools-lambda-java/issues/1453))
- Add Serveless Framework example ([#1363](https://github.com/aws-powertools/powertools-lambda-java/issues/1363))
- Fix link to SQS large message migration guide ([#1422](https://github.com/aws-powertools/powertools-lambda-java/issues/1422))
- Change link to absolute versioned path for examples ([#1374](https://github.com/aws-powertools/powertools-lambda-java/issues/1374))
- **customer-reference:** add Vertex Pharmaceuticals as a customer reference ([#1486](https://github.com/aws-powertools/powertools-lambda-java/issues/1486))
- **logging:** align example cloudwatch example to correct output from code: lambda_request_id --> function_request_id ([#1411](https://github.com/aws-powertools/powertools-lambda-java/issues/1411))
## Features
- ALC ([#1514](https://github.com/aws-powertools/powertools-lambda-java/issues/1514))
- Add support for POWERTOOLS_LOGGER_LOG_EVENT ([#1510](https://github.com/aws-powertools/powertools-lambda-java/issues/1510))
- Terraform example ([#1478](https://github.com/aws-powertools/powertools-lambda-java/issues/1478))
## Maintenance
- Addition of Warn Message If Invalid Annotation Key While Tracing [#1511](https://github.com/aws-powertools/powertools-lambda-java/issues/1511) ([#1512](https://github.com/aws-powertools/powertools-lambda-java/issues/1512))
- artifacts size on good branches ([#1493](https://github.com/aws-powertools/powertools-lambda-java/issues/1493))
- add missing projects and improve workflow ([#1487](https://github.com/aws-powertools/powertools-lambda-java/issues/1487))
- java21 support in our build ([#1488](https://github.com/aws-powertools/powertools-lambda-java/issues/1488))
- Reporting size of the jars in GitHub comments ([#1196](https://github.com/aws-powertools/powertools-lambda-java/issues/1196))
- secure github actions using hash instead of versions ([#1232](https://github.com/aws-powertools/powertools-lambda-java/issues/1232))
## [v1.17.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.16.1...v1.17.0) - 2023-08-21
## Bug Fixes
- Roll log4j shade transformer forwards ([#1376](https://github.com/aws-powertools/powertools-lambda-java/issues/1376))
- Rollback doc changes ([#1323](https://github.com/aws-powertools/powertools-lambda-java/issues/1323))
- use default credentials provider for all provided SDK clients ([#1303](https://github.com/aws-powertools/powertools-lambda-java/issues/1303))
## Documentation
- Adding CDK example ([#1321](https://github.com/aws-powertools/powertools-lambda-java/issues/1321))
- improve contributing guide ([#1334](https://github.com/aws-powertools/powertools-lambda-java/issues/1334))
- Add maintainers guide ([#1326](https://github.com/aws-powertools/powertools-lambda-java/issues/1326))
- versioning - fix typo ([#1322](https://github.com/aws-powertools/powertools-lambda-java/issues/1322))
- add support for docs versioning ([#1239](https://github.com/aws-powertools/powertools-lambda-java/issues/1239)) ([#1293](https://github.com/aws-powertools/powertools-lambda-java/issues/1293))
- Started cleaning up example doc ([#1291](https://github.com/aws-powertools/powertools-lambda-java/issues/1291))
## Features
- Add Batch Processor module ([#1317](https://github.com/aws-powertools/powertools-lambda-java/issues/1317))
- large message in SQS and SNS ([#1310](https://github.com/aws-powertools/powertools-lambda-java/issues/1310))
## Maintenance
- Fix missing version change pieces ([#1382](https://github.com/aws-powertools/powertools-lambda-java/issues/1382))
- apply checkstyle again ([#1339](https://github.com/aws-powertools/powertools-lambda-java/issues/1339))
- Add powertools specific user-agent-suffix to the AWS SDK v2 clients ([#1306](https://github.com/aws-powertools/powertools-lambda-java/issues/1306))
- checkstyle formater & linter ([#1316](https://github.com/aws-powertools/powertools-lambda-java/issues/1316))
- update poms to SNAPSHOT version for dev ([#1299](https://github.com/aws-powertools/powertools-lambda-java/issues/1299))
## [v1.16.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.16.0...v1.16.1) - 2023-07-19
## Bug Fixes
- idempotency timeout bug ([#1285](https://github.com/aws-powertools/powertools-lambda-java/issues/1285))
- ParamManager cannot provide default SSM & Secrets providers ([#1282](https://github.com/aws-powertools/powertools-lambda-java/issues/1282))
- Handle batch failures in FIFO queues correctly ([#1183](https://github.com/aws-powertools/powertools-lambda-java/issues/1183))
- examples shouldn't be deployed to mvn central ([#1253](https://github.com/aws-powertools/powertools-lambda-java/issues/1253))
## Documentation
- update README.md ([#1294](https://github.com/aws-powertools/powertools-lambda-java/issues/1294))
- adding our customer references ([#1287](https://github.com/aws-powertools/powertools-lambda-java/issues/1287))
- update documentation for aspectJ ([#1273](https://github.com/aws-powertools/powertools-lambda-java/issues/1273))
## Maintenance
- **unit-test:** Add missing unit tests in modules with low coverage ([#1264](https://github.com/aws-powertools/powertools-lambda-java/issues/1264))
## [v1.16.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.15.0...v1.16.0) - 2023-06-29
## Bug Fixes
- e2e tests on JDK8 ([#1225](https://github.com/aws-powertools/powertools-lambda-java/issues/1225))
- codecov URL ([#1222](https://github.com/aws-powertools/powertools-lambda-java/issues/1222))
- remove GH pages ([#1211](https://github.com/aws-powertools/powertools-lambda-java/issues/1211))
- update references to other variants
- missing idempotency key should not persist any data ([#1201](https://github.com/aws-powertools/powertools-lambda-java/issues/1201))
- **docs:** add site_url to docs
## Features
- Add AppConfig provider to parameters module ([#1104](https://github.com/aws-powertools/powertools-lambda-java/issues/1104))
- end-to-end tests for core modules and idempotency ([#970](https://github.com/aws-powertools/powertools-lambda-java/issues/970))
- **docs:** adds S3 Docs uploader
## Maintenance
- Update docs base origin url ([#1238](https://github.com/aws-powertools/powertools-lambda-java/issues/1238))
- E2E tests GitHub action ([#1175](https://github.com/aws-powertools/powertools-lambda-java/issues/1175))
- add all java versions and use corretto for build ([#1191](https://github.com/aws-powertools/powertools-lambda-java/issues/1191))
- Change repo URL to the new location ([#1171](https://github.com/aws-powertools/powertools-lambda-java/issues/1171))
- Swap implementation of `aspectj-maven-plugin` to support Java 17 ([#1172](https://github.com/aws-powertools/powertools-lambda-java/issues/1172))
- update e2e-tests with latest Powertools version ([#1173](https://github.com/aws-powertools/powertools-lambda-java/issues/1173))
- rename project from Powertools to Powertools for AWS Lambda (Java) ([#1169](https://github.com/aws-powertools/powertools-lambda-java/issues/1169))
- **ci:** add workflow to dispatch analytics fetching ([#1143](https://github.com/aws-powertools/powertools-lambda-java/issues/1143))
## [v1.15.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.14.0...v1.15.0) - 2023-03-21
## Bug Fixes
- **cloudformation-module:** Use physicalResourceId when not provided by custom resource ([#1082](https://github.com/aws-powertools/powertools-lambda-java/issues/1082))
## Documentation
- **cloudformation-module:** Improve Docs ([#1090](https://github.com/aws-powertools/powertools-lambda-java/issues/1090))
- **plugin:** fix mdocs and git revision plugin integration ([#1066](https://github.com/aws-powertools/powertools-lambda-java/issues/1066))
## Features
- Add DynamoDB provider to parameters module ([#1091](https://github.com/aws-powertools/powertools-lambda-java/issues/1091))
## Maintenance
- update the project version to 1.15.0 ([#1097](https://github.com/aws-powertools/powertools-lambda-java/issues/1097))
- **governance:** update issue templates ([#1062](https://github.com/aws-powertools/powertools-lambda-java/issues/1062))
- **metrics:** deprecate withMetricLogger in favor of withMetricsLogger ([#1060](https://github.com/aws-powertools/powertools-lambda-java/issues/1060))
## [v1.14.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.13.0...v1.14.0) - 2023-02-17
## Documentation
- **home:** update powertools definition
## Features
- **metrics:** introduce MetricsUtils.withMetricsLogger utility ([#1000](https://github.com/aws-powertools/powertools-lambda-java/issues/1000))
## Maintenance
- update the project version to 1.14.0 ([#1052](https://github.com/aws-powertools/powertools-lambda-java/issues/1052))
## [v1.13.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.12.3...v1.13.0) - 2022-12-14
## Bug Fixes
- envelope is not taken into account with built-in types ([#960](https://github.com/aws-powertools/powertools-lambda-java/issues/960))
## Documentation
- add missing grammar article ([#976](https://github.com/aws-powertools/powertools-lambda-java/issues/976))
## Features
- **idempotency:** handle lambda timeout scenarios for INPROGRESS records ([#933](https://github.com/aws-powertools/powertools-lambda-java/issues/933))
## Maintenance
- update the project version to 1.13.0 ([#1018](https://github.com/aws-powertools/powertools-lambda-java/issues/1018))
## [v1.12.3](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.12.2...v1.12.3) - 2022-07-12
## Maintenance
- **ci:** fix build ([#853](https://github.com/aws-powertools/powertools-lambda-java/issues/853))
- **ci:** Address GitHub workaround for CVE-2022-24765.
- **ci:** upgrade to checkout v3
## [v1.12.2](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.12.1...v1.12.2) - 2022-04-29
## Bug Fixes
- remove local implementation of PayloadS3Pointer.java and use payloadoffloading-common ([#851](https://github.com/aws-powertools/powertools-lambda-java/issues/851))
## [v1.12.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.12.0...v1.12.1) - 2022-04-21
## Bug Fixes
- disable idempotency doesn't disable dynamodb client creation in persistent store ([#796](https://github.com/aws-powertools/powertools-lambda-java/issues/796))
## Maintenance
- correct bug fix release number
- **docs:** additional rename of project name ([#781](https://github.com/aws-powertools/powertools-lambda-java/issues/781)) ([#789](https://github.com/aws-powertools/powertools-lambda-java/issues/789))
## Reverts
- chore: correct bug fix release number
## [v1.12.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.11.0...v1.12.0) - 2022-03-01
## Bug Fixes
- **docs:** fix title for custom resources page ([#763](https://github.com/aws-powertools/powertools-lambda-java/issues/763))
## Features
- Easy Event Deserialization ([#757](https://github.com/aws-powertools/powertools-lambda-java/issues/757))
## Maintenance
- remove examples from the project as it was moved to aws-lambda-powertools-examples ([#772](https://github.com/aws-powertools/powertools-lambda-java/issues/772))
- remove SQS and Idempotency examples ([#754](https://github.com/aws-powertools/powertools-lambda-java/issues/754))
- downgrade release plugin to validate release fail issue
- downgrade release plugin to validate release fail issue
## [v1.11.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.10.3...v1.11.0) - 2022-02-16
## Maintenance
- **docs:** FAQ for Kotlin projects
- **docs:** Clarify test config needed for Tracing module ([#735](https://github.com/aws-powertools/powertools-lambda-java/issues/735))
- **docs:** typo in CHANGELOG.md
## [v1.10.3](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.10.2...v1.10.3) - 2022-02-01
## Bug Fixes
- Prevent message to be marked as success if failed sending to DLQ ([#731](https://github.com/aws-powertools/powertools-lambda-java/issues/731))
- **gradle:** Fix gradle example and docs to work with java 12+ ([#703](https://github.com/aws-powertools/powertools-lambda-java/issues/703))
## Maintenance
- move core utilities example to aws-samples/aws-lambda-powertools-examples ([#733](https://github.com/aws-powertools/powertools-lambda-java/issues/733))
- Update readme to refer examples repo
- **ci:** set release env variable for auto closing issue
## [v1.10.2](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.10.1...v1.10.2) - 2022-01-07
## Features
- **tracing:** ability to override object mapper ([#698](https://github.com/aws-powertools/powertools-lambda-java/issues/698))
## Maintenance
- Automate release prep ([#696](https://github.com/aws-powertools/powertools-lambda-java/issues/696))
- **automation:** find replace pom.xml at all levels
- **automation:** find replace pom.xml at all levels
- **docs:** Add FAQs section to docs with information about Lombok support. ([#680](https://github.com/aws-powertools/powertools-lambda-java/issues/680))
## [v1.10.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.10.0...v1.10.1) - 2022-01-06
## Features
- **ci:** auto-notify & close issues on release
## Maintenance
- prep release 1.10.1
- action to automate release prep
- action to automate release prep
- **docs:** Latest version of aspectj.post-compile-weaving
- **docs:** Full gradle config in example for each module
- **docs:** use free fair gradle aspect plugin ([#679](https://github.com/aws-powertools/powertools-lambda-java/issues/679))
## [v1.10.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.9.1...v1.10.0) - 2021-12-27
## [v1.9.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.8.3...v1.9.1) - 2021-12-27
## Bug Fixes
- support batch size greater than 10 processing ([#667](https://github.com/aws-powertools/powertools-lambda-java/issues/667))
## Features
- Json layout modern implementation ([#670](https://github.com/aws-powertools/powertools-lambda-java/issues/670))
## Maintenance
- prep release 1.10.0 ([#671](https://github.com/aws-powertools/powertools-lambda-java/issues/671))
- Fix docs layout
## [v1.8.3](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.9.0...v1.8.3) - 2021-12-21
## [v1.9.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.8.2...v1.9.0) - 2021-12-21
## Features
- **tracing:** add service annotation ([#655](https://github.com/aws-powertools/powertools-lambda-java/issues/655))
## Maintenance
- prep release 1.9.0 ([#666](https://github.com/aws-powertools/powertools-lambda-java/issues/666))
- localise abstract json layout implementation ([#664](https://github.com/aws-powertools/powertools-lambda-java/issues/664))
- Update edit url prefix on doc
- Update docs to reflect latest gradle plugin fix ([#656](https://github.com/aws-powertools/powertools-lambda-java/issues/656))
## [v1.8.2](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.8.1...v1.8.2) - 2021-12-15
## Maintenance
- prep release 1.8.2 ([#653](https://github.com/aws-powertools/powertools-lambda-java/issues/653))
## [v1.8.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.8.0...v1.8.1) - 2021-12-10
## Documentation
- **tenets:** update Idiomatic tenet to Progressive ([#615](https://github.com/aws-powertools/powertools-lambda-java/issues/615))
## Maintenance
- prep release 1.8.1 ([#647](https://github.com/aws-powertools/powertools-lambda-java/issues/647))
## [v1.8.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.7.3...v1.8.0) - 2021-11-05
## Bug Fixes
- LoggingAspect precedence to be last for accepting mutated args ([#567](https://github.com/aws-powertools/powertools-lambda-java/issues/567))
## Features
- create Java cfn-response equivalent ([#558](https://github.com/aws-powertools/powertools-lambda-java/issues/558)) ([#560](https://github.com/aws-powertools/powertools-lambda-java/issues/560))
## Maintenance
- prep release 1.8.0 ([#608](https://github.com/aws-powertools/powertools-lambda-java/issues/608))
- Fix failing build and auto merge only when build is success
- spotbug check ([#565](https://github.com/aws-powertools/powertools-lambda-java/issues/565))
- Fix/Ignore spotbugs violations
## [v1.7.3](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.7.2...v1.7.3) - 2021-09-14
## Bug Fixes
- reset cold start only when placed on handler ([#508](https://github.com/aws-powertools/powertools-lambda-java/issues/508))
## Documentation
- **batch-processing:** Support for moving non retryable msg to DLQ ([#531](https://github.com/aws-powertools/powertools-lambda-java/issues/531))
## Features
- **batch-processing:** move non retry-able message to DLQ ([#500](https://github.com/aws-powertools/powertools-lambda-java/issues/500))
## Maintenance
- prep release 1.7.3
## [v1.7.2](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.7.1...v1.7.2) - 2021-08-03
## Documentation
- status badges
## Maintenance
- prep release 1.7.2 ([#490](https://github.com/aws-powertools/powertools-lambda-java/issues/490))
- Upgrade to latest(1.14.0) aspectj-maven-plugin ([#489](https://github.com/aws-powertools/powertools-lambda-java/issues/489))
- Logging and SQS utility Optimisations ([#484](https://github.com/aws-powertools/powertools-lambda-java/issues/484))
- wait for merge until check is green
- wait for merge until check is green
- wait for spotbugs check before automerge
## [v1.7.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.7.0...v1.7.1) - 2021-07-06
## Maintenance
- prep release 1.7.1 ([#459](https://github.com/aws-powertools/powertools-lambda-java/issues/459))
## [v1.7.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.6.0...v1.7.0) - 2021-07-05
## Features
- Clear logger state ([#453](https://github.com/aws-powertools/powertools-lambda-java/issues/453))
## Maintenance
- prep release 1.7.0 ([#457](https://github.com/aws-powertools/powertools-lambda-java/issues/457))
## [v1.6.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.5.0...v1.6.0) - 2021-06-20
## Features
- [#421](https://github.com/aws-powertools/powertools-lambda-java/issues/421) Support for Boolean and Number type as value in TracingUtils putAnnotation ([#423](https://github.com/aws-powertools/powertools-lambda-java/issues/423))
- logger-Remove custom keys interface ([#395](https://github.com/aws-powertools/powertools-lambda-java/issues/395))
## Maintenance
- prep release 1.6.0 ([#436](https://github.com/aws-powertools/powertools-lambda-java/issues/436))
- setup-java v2 ([#353](https://github.com/aws-powertools/powertools-lambda-java/issues/353))
- add JDK 16 to build matrix ([#367](https://github.com/aws-powertools/powertools-lambda-java/issues/367))
## [v1.5.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.4.0...v1.5.0) - 2021-03-31
## Features
- remove deprecated attributes on Tracing annotation ([#330](https://github.com/aws-powertools/powertools-lambda-java/issues/330))
## Maintenance
- prep release 1.5.0 ([#345](https://github.com/aws-powertools/powertools-lambda-java/issues/345))
- rename automerge workflow name
- fix auto merge dependabot PR ([#342](https://github.com/aws-powertools/powertools-lambda-java/issues/342))
## [v1.4.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.3.0...v1.4.0) - 2021-03-11
## Bug Fixes
- null check on dimension
## Features
- Default dimensions from powertools instead of emf library ([#317](https://github.com/aws-powertools/powertools-lambda-java/issues/317))
## Maintenance
- prep release 1.4.0 ([#324](https://github.com/aws-powertools/powertools-lambda-java/issues/324))
## [v1.3.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.2.0...v1.3.0) - 2021-03-05
## Bug Fixes
- powertools specific log level env var to not conflict with the system LOG_LEVEL ([#306](https://github.com/aws-powertools/powertools-lambda-java/issues/306))
- **example:** Update the example to v1.2.0 ([#288](https://github.com/aws-powertools/powertools-lambda-java/issues/288))
## Documentation
- ability to override object mapper used for logging event ([#303](https://github.com/aws-powertools/powertools-lambda-java/issues/303))
## Features
- single metric utility method to pick default namespace ([#305](https://github.com/aws-powertools/powertools-lambda-java/issues/305))
- ability to override object mapper used for logging event ([#302](https://github.com/aws-powertools/powertools-lambda-java/issues/302))
- respect code guru profile handler implementation ([#304](https://github.com/aws-powertools/powertools-lambda-java/issues/304))
- capture metrics even when handler results in exception ([#286](https://github.com/aws-powertools/powertools-lambda-java/issues/286))
## Maintenance
- Prep release 1.3.0 ([#316](https://github.com/aws-powertools/powertools-lambda-java/issues/316))
- migrate docs from gatsby to mkdocs ([#308](https://github.com/aws-powertools/powertools-lambda-java/issues/308))
- consistent field names for trace and req id with logger ([#309](https://github.com/aws-powertools/powertools-lambda-java/issues/309))
## [v1.2.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.1.0...v1.2.0) - 2021-01-13
## Code Refactoring
- replace Apache Commons Logging with SLF4J ([#212](https://github.com/aws-powertools/powertools-lambda-java/issues/212))
## Documentation
- shadow sidebar to remain expanded ([#208](https://github.com/aws-powertools/powertools-lambda-java/issues/208))
## Features
- support for env variable in tracing capture modes ([#249](https://github.com/aws-powertools/powertools-lambda-java/issues/249))
- custom segment names ([#221](https://github.com/aws-powertools/powertools-lambda-java/issues/221))
## Maintenance
- Prep release 1.2.0 ([#250](https://github.com/aws-powertools/powertools-lambda-java/issues/250))
- Consistent env variable names for tracing ([#251](https://github.com/aws-powertools/powertools-lambda-java/issues/251))
- update docs dependencies ([#214](https://github.com/aws-powertools/powertools-lambda-java/issues/214))
## [v1.1.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.0.1...v1.1.0) - 2020-12-03
## Documentation
- add source code link in nav bar ([#199](https://github.com/aws-powertools/powertools-lambda-java/issues/199))
## Features
- Parameters injection ([#201](https://github.com/aws-powertools/powertools-lambda-java/issues/201))
## Maintenance
- Prep release 1.1.0 ([#205](https://github.com/aws-powertools/powertools-lambda-java/issues/205))
## [v1.0.1](https://github.com/aws-powertools/powertools-lambda-java/compare/v1.0.0...v1.0.1) - 2020-11-26
## Bug Fixes
- fixing dependencies security issues ([#169](https://github.com/aws-powertools/powertools-lambda-java/issues/169))
## Maintenance
- Prep for release (1.0.1) ([#198](https://github.com/aws-powertools/powertools-lambda-java/issues/198))
- upgrade AspectjGradlePlugin to latest and example project to java 11 ([#189](https://github.com/aws-powertools/powertools-lambda-java/issues/189))
## Performance Improvements
- Make UrlConnectionHttpClient default client for params fetch ([#185](https://github.com/aws-powertools/powertools-lambda-java/issues/185))
## [v1.0.0](https://github.com/aws-powertools/powertools-lambda-java/compare/v0.6.0-beta...v1.0.0) - 2020-11-04
## Bug Fixes
- **docs:** Correct url and not for gradle ([#158](https://github.com/aws-powertools/powertools-lambda-java/issues/158))
## Code Refactoring
- Rename helpers for validation module ([#167](https://github.com/aws-powertools/powertools-lambda-java/issues/167))
- Rename annotations for GA ([#165](https://github.com/aws-powertools/powertools-lambda-java/issues/165))
## [v0.6.0-beta](https://github.com/aws-powertools/powertools-lambda-java/compare/v0.5.0-beta...v0.6.0-beta) - 2020-10-27
## Documentation
- Update all the environment variables used ([#127](https://github.com/aws-powertools/powertools-lambda-java/issues/127))
## Features
- log aws request id ([#133](https://github.com/aws-powertools/powertools-lambda-java/issues/133))
## Maintenance
- Prepare for 0.6.0-beta ([#155](https://github.com/aws-powertools/powertools-lambda-java/issues/155))
- gradle example ([#147](https://github.com/aws-powertools/powertools-lambda-java/issues/147))
## [v0.5.0-beta](https://github.com/aws-powertools/powertools-lambda-java/compare/v0.4.0-beta...v0.5.0-beta) - 2020-10-06
## Features
- SQS Partial batch Utility ([#120](https://github.com/aws-powertools/powertools-lambda-java/issues/120))
## Maintenance
- Prepare for 0.5.0-beta ([#124](https://github.com/aws-powertools/powertools-lambda-java/issues/124))
## [v0.4.0-beta](https://github.com/aws-powertools/powertools-lambda-java/compare/v0.3.1-beta...v0.4.0-beta) - 2020-10-02
## Bug Fixes
- Log event via object mapper and not depend on toString ([#113](https://github.com/aws-powertools/powertools-lambda-java/issues/113))
## Features
- integration with CloudWatch ServiceLens [#88](https://github.com/aws-powertools/powertools-lambda-java/issues/88) ([#111](https://github.com/aws-powertools/powertools-lambda-java/issues/111))
## [v0.3.1-beta](https://github.com/aws-powertools/powertools-lambda-java/compare/v0.3.0-beta...v0.3.1-beta) - 2020-09-25
## Bug Fixes
- Removing Log4J dependencies from the tracing module. ([#106](https://github.com/aws-powertools/powertools-lambda-java/issues/106))
- Removing v1 Java SDK dependencies for X-Ray ([#105](https://github.com/aws-powertools/powertools-lambda-java/issues/105))
## Documentation
- fixes to the documentation ([#102](https://github.com/aws-powertools/powertools-lambda-java/issues/102))
## [v0.3.0-beta](https://github.com/aws-powertools/powertools-lambda-java/compare/v0.2.0-beta...v0.3.0-beta) - 2020-09-22
## Features
- Metrics utility ([#91](https://github.com/aws-powertools/powertools-lambda-java/issues/91))
## [v0.2.0-beta](https://github.com/aws-powertools/powertools-lambda-java/compare/v0.1.0-beta...v0.2.0-beta) - 2020-09-01
## Bug Fixes
- **general:** clean up typos and code ([#62](https://github.com/aws-powertools/powertools-lambda-java/issues/62))
## Documentation
- Readme update ([#72](https://github.com/aws-powertools/powertools-lambda-java/issues/72))
- Update SQS large payload docs ([#60](https://github.com/aws-powertools/powertools-lambda-java/issues/60))
- fixing documentation ([#59](https://github.com/aws-powertools/powertools-lambda-java/issues/59))
## Features
- Utility without annotation ([#61](https://github.com/aws-powertools/powertools-lambda-java/issues/61))
- SQS Large message handling ([#55](https://github.com/aws-powertools/powertools-lambda-java/issues/55))
## v0.1.0-beta - 2020-08-31
## Bug Fixes
- Fixing security issues on package.json dependencies ([#22](https://github.com/aws-powertools/powertools-lambda-java/issues/22))
- Fixing package versions for security purpose ([#16](https://github.com/aws-powertools/powertools-lambda-java/issues/16))
- Rename Java ArtifactId and GroupId to be compliant with new AWS standard.
- docs pipeline
- Fix Readme.md documentation and remove unecessary parts.
## Code Refactoring
- consistent naming of powertools tracing and initial docs. ([#48](https://github.com/aws-powertools/powertools-lambda-java/issues/48))
- consistent naming of powertools. ([#46](https://github.com/aws-powertools/powertools-lambda-java/issues/46))
- Split Tracing and Logging packages Dependency split ([#45](https://github.com/aws-powertools/powertools-lambda-java/issues/45))
- move groupId from software.aws.lambda to softwarte.amazon.lambda ([#23](https://github.com/aws-powertools/powertools-lambda-java/issues/23))
## Documentation
- Adding license to each source file ([#44](https://github.com/aws-powertools/powertools-lambda-java/issues/44))
- Initial javadocs for PowerLogger class. ([#43](https://github.com/aws-powertools/powertools-lambda-java/issues/43))
- Implement Logger and Tracer part ([#27](https://github.com/aws-powertools/powertools-lambda-java/issues/27))
- Initial javadocs for our logging annotation. ([#40](https://github.com/aws-powertools/powertools-lambda-java/issues/40))
- update maven artifactId and groupId to new one
- Improving README file
- Init project documentation ci: init Github actions flow
## Pull Requests
- Merge pull request [#1](https://github.com/aws-powertools/powertools-lambda-java/issues/1) from stevehouel/master
## Overview
Our public roadmap outlines the high level direction we are working towards. We update this document when our priorities change: security and stability are our top priority.
### Key areas
Security and operational excellence take precedence above all else. This means bug fixing, stability, customer's support, and internal compliance may delay one or more key areas below.
We may choose to re-prioritize or defer items based on customer feedback, security, and operational impacts, and business value.
#### Release Security (p0)
Our top priority is to establish the processes and infrastructure needed for a fully automated and secure end-to-end release process of new versions to Maven Central.
- [Implement GitHub workflows](https://github.com/aws-powertools/powertools-lambda-java/issues/1231) and create infrastructure to release to Maven Central
- [Implement end-to-end tests](https://github.com/aws-powertools/powertools-lambda-java/issues/1815)
- Implement [OpenSSF Scorecard](https://openssf.org/projects/scorecard/)
#### `v2` Release: Consistency and Ecosystem (p1)
As part of a new major version `v2` release, we prioritize the Java project's consistency of core utilities (Logging, Metrics, Tracing) with the other runtimes (Python, TypeScript, .NET). Additionally, we will focus on integrating the library with popular technologies and frameworks from the Java and AWS ecosystem. Particularly, we aim at leveraging new techniques to allow customers to reduce Lambda cold-start time. The `v2` release will also drop support for Java 8 moving to Java 11 as the baseline.
##### Core Utilities
- [Review public interfaces and reduce public API surface area](https://github.com/aws-powertools/powertools-lambda-java/issues/1283)
- [Release Logging `v2` module](https://github.com/aws-powertools/powertools-lambda-java/issues/965) allowing customers to choose the logging framework and adding support for logging deeply nested objects as JSON
- [Support high resolution metrics](https://github.com/aws-powertools/powertools-lambda-java/issues/1041)
- [Improve modularity of metrics module](https://github.com/aws-powertools/powertools-lambda-java/issues/1848) to remove coupling with EMF library and enable future support for additional metrics providers / backends
##### Ecosystem
- [Add GraalVM support for core utilities](https://github.com/aws-powertools/powertools-lambda-java/issues/764)
- [Implement priming using CRaC to improve AWS Snapstart support](https://github.com/aws-powertools/powertools-lambda-java/issues/1588)
- [Evaluate integration with popular Java frameworks such as Micronaut, Spring Cloud Function, or Quarkus](https://github.com/aws-powertools/powertools-lambda-java/issues/1701)
##### Other
- [Validation module integration with HTTP requests](https://github.com/aws-powertools/powertools-lambda-java/issues/1298)
- [Support validation module from within the batch module](https://github.com/aws-powertools/powertools-lambda-java/issues/1496)
- [Add support for parallel processing in Batch Processing utility](https://github.com/aws-powertools/powertools-lambda-java/issues/1540)
- [Documentation: Review and improve documentation to be consistent with other runtimes](https://github.com/aws-powertools/powertools-lambda-java/issues/1352)
#### Feature Parity (p2)
If priorities `p0` and `p1` are addressed, we will also focus on feature parity of non-core utilities. This allows customers to achieve better standardization of their development processes across different Powertools runtimes.
- [Re-evaluate if there is a need for adding a lightweight customer Powertools event handler](https://github.com/aws-powertools/powertools-lambda-java/issues/1103)
- Add comprehensive GraalVM support for all utilities
- [Add Feature Flags module](https://github.com/aws-powertools/powertools-lambda-java/issues/1086)
- [Add S3 Streaming module](https://github.com/aws-powertools/powertools-lambda-java/issues/1085)
- Add support for Data Masking during JSON serialization
### Missing something?
You can help us prioritize by [upvoting existing feature requests](https://github.com/aws-powertools/powertools-lambda-java/issues?q=is%3Aissue%20state%3Aopen%20label%3Aenhancement), leaving a comment on what use cases it could unblock for you, and by joining our discussions on Discord.
### Roadmap status definition
```
graph LR
Ideas --> Backlog --> Work["Working on it"] --> Merged["Coming soon"] --> Shipped
```
*Visual representation*
Within our [public board](https://github.com/orgs/aws-powertools/projects/4/), you'll see the following values in the `Status` column:
- **Ideas**. Incoming and existing feature requests that are not being actively considered yet. These will be reviewed when bandwidth permits.
- **Backlog**. Accepted feature requests or enhancements that we want to work on.
- **Working on it**. Features or enhancements we're currently either researching or implementing it.
- **Coming soon**. Any feature, enhancement, or bug fixes that have been merged and are coming in the next release.
- **Shipped**. Features or enhancements that are now available in the most recent release.
> Tasks or issues with empty `Status` will be categorized in upcoming review cycles.
### Process
```
graph LR
PFR[Feature request] --> Triage{Need RFC?}
Triage --> |Complex/major change or new utility?| RFC[Ask or write RFC] --> Approval{Approved?}
Triage --> |Minor feature or enhancement?| NoRFC[No RFC required] --> Approval
Approval --> |Yes| Backlog
Approval --> |No | Reject["Inform next steps"]
Backlog --> |Prioritized| Implementation
Backlog --> |Defer| WelcomeContributions["help-wanted label"]
```
*Visual representation*
Our end-to-end mechanism follows four major steps:
- **Feature Request**. Ideas start with a [feature request](https://github.com/aws-powertools/powertools-lambda-java/issues/new?template=feature_request.md) to outline their use case at a high level. For complex use cases, maintainers might ask for/write a RFC.
- Maintainers review requests based on [project tenets](../#tenets), customers reaction (👍), and use cases.
- **Request-for-comments (RFC)**. Design proposals use our [RFC template](https://github.com/aws-powertools/powertools-lambda-java/issues/new?q=is%3Aissue+state%3Aopen+label%3Aenhancement&template=rfc.md) to describe its implementation, challenges, developer experience, dependencies, and alternative solutions.
- This helps refine the initial idea with community feedback before a decision is made.
- **Decision**. After carefully reviewing and discussing them, maintainers make a final decision on whether to start implementation, defer or reject it, and update everyone with the next steps.
- **Implementation**. For approved features, maintainers give priority to the original authors for implementation unless it is a sensitive task that is best handled by maintainers.
See [Maintainers](../processes/maintainers/) document to understand how we triage issues and pull requests, labels and governance.
### Disclaimer
The Powertools for AWS Lambda (Java) team values feedback and guidance from its community of users, although final decisions on inclusion into the project will be made by AWS.
We determine the high-level direction for our open roadmap based on customer feedback and popularity (👍🏽 and comments), security and operational impacts, and business value. Where features don’t meet our goals and longer-term strategy, we will communicate that clearly and openly as quickly as possible with an explanation of why the decision was made.
### FAQs
**Q: Why did you build this?**
A: We know that our customers are making decisions and plans based on what we are developing, and we want to provide our customers the insights they need to plan.
**Q: Why are there no dates on your roadmap?**
A: Because job zero is security and operational stability, we can't provide specific target dates for features. The roadmap is subject to change at any time, and roadmap issues in this repository do not guarantee a feature will be launched as proposed.
**Q: How can I provide feedback or ask for more information?**
A: For existing features, you can directly comment on issues. For anything else, please open an issue.
Powertools for AWS Lambda (Java) is a collection of utilities designed to help you build serverless applications on AWS.
The toolkit is modular, so you can pick and choose the utilities you need for your application, but also combine them for a complete solution for your serverless applications.
## Patterns
Many of the utilities provided can be used with different patterns, depending on your preferences and the structure of your code.
### AspectJ Annotation
If you prefer using annotations to apply cross-cutting concerns to your Lambda handlers, the AspectJ annotation pattern is a good fit. This approach lets you decorate methods with Powertools utilities using annotations, applying their functionality with minimal code changes.
This pattern works well when you want to keep your business logic clean and separate concerns using aspect-oriented programming.
Note
This approach requires configuring AspectJ compile-time weaving in your build tool (Maven or Gradle). See the [installation guide](../#install) for setup instructions.
```
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.lambda.powertools.logging.CorrelationIdPaths;
import software.amazon.lambda.powertools.logging.Logging;
public class App implements RequestHandler {
private static final Logger log = LoggerFactory.getLogger(App.class);
@Logging(logEvent = true, correlationIdPath = CorrelationIdPaths.API_GATEWAY_REST)
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
log.info("Processing request");
return new APIGatewayProxyResponseEvent().withStatusCode(200).withBody("Success");
}
}
```
```
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import software.amazon.lambda.powertools.metrics.FlushMetrics;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.metrics.MetricsFactory;
import software.amazon.lambda.powertools.metrics.model.MetricUnit;
public class App implements RequestHandler {
private static final Metrics metrics = MetricsFactory.getMetricsInstance();
@FlushMetrics(namespace = "ServerlessApp", service = "payment")
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
metrics.addMetric("SuccessfulBooking", 1, MetricUnit.COUNT);
return new APIGatewayProxyResponseEvent().withStatusCode(200).withBody("Success");
}
}
```
```
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import software.amazon.lambda.powertools.tracing.Tracing;
import software.amazon.lambda.powertools.tracing.TracingUtils;
public class App implements RequestHandler {
@Tracing
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
TracingUtils.putAnnotation("operation", "payment");
return processPayment();
}
@Tracing
private APIGatewayProxyResponseEvent processPayment() {
return new APIGatewayProxyResponseEvent().withStatusCode(200).withBody("Success");
}
}
```
### Functional Approach
If you prefer a more functional programming style or want to avoid AspectJ configuration, you can use the Powertools for AWS Lambda (Java) utilities directly in your code. This approach is more explicit and provides full control over how the utilities are applied.
This pattern is ideal when you want to avoid AspectJ setup or prefer a more imperative style. It also eliminates the AspectJ runtime dependency, making your deployment package more lightweight.
```
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.lambda.powertools.logging.CorrelationIdPaths;
import software.amazon.lambda.powertools.logging.PowertoolsLogging;
public class App implements RequestHandler {
private static final Logger log = LoggerFactory.getLogger(App.class);
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
return PowertoolsLogging.withLogging(
context,
0.7,
CorrelationIdPaths.API_GATEWAY_REST,
input,
() -> processRequest(input));
}
private APIGatewayProxyResponseEvent processRequest(APIGatewayProxyRequestEvent input) {
// do something with input
log.info("Processing request");
return new APIGatewayProxyResponseEvent().withStatusCode(200).withBody("Success");
}
}
```
```
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import software.amazon.lambda.powertools.metrics.Metrics;
import software.amazon.lambda.powertools.metrics.MetricsFactory;
import software.amazon.lambda.powertools.metrics.model.MetricUnit;
public class App implements RequestHandler {
private static final Metrics metrics = MetricsFactory.getMetricsInstance();
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
try {
metrics.addMetric("SuccessfulBooking", 1, MetricUnit.COUNT);
return new APIGatewayProxyResponseEvent().withStatusCode(200).withBody("Success");
} finally {
metrics.flush();
}
}
}
```
```
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent;
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent;
import software.amazon.lambda.powertools.tracing.TracingUtils;
public class App implements RequestHandler {
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
TracingUtils.withSubsegment("processPayment", subsegment -> {
subsegment.putAnnotation("operation", "payment");
// Business logic here
});
return new APIGatewayProxyResponseEvent().withStatusCode(200).withBody("Success");
}
}
```
Note
The functional approach is available for all utilities. Further examples and detailed usage can be found in the individual documentation pages for each utility.
# Core Utilities
Logging provides an opinionated logger with output structured as JSON.
## Key features
- Leverages standard logging libraries: [*SLF4J*](https://www.slf4j.org/) as the API, and [*log4j2*](https://logging.apache.org/log4j/2.x/) or [*logback*](https://logback.qos.ch/) for the implementation
- Captures key fields from Lambda context, cold start and structures logging output as JSON
- Optionally logs Lambda request
- Optionally logs Lambda response
- Optionally supports log sampling by including a configurable percentage of DEBUG logs in logging output
- Optionally supports buffering lower level logs and flushing them on error or manually
- Allows additional keys to be appended to the structured log at any point in time
- GraalVM support
## Getting started
Tip
You can find complete examples in the [project repository](https://github.com/aws-powertools/powertools-lambda-java/tree/v2/examples/powertools-examples-core-utilities).
### Installation
Depending on preference, you must choose to use either *log4j2* or *logback* as your log provider. If you use the AspectJ annotation approach, you need to configure *aspectj* to weave the code and make sure the annotation is processed. If you prefer the [functional approach](../../usage-patterns/#functional-approach), AspectJ configuration is not required.
#### Maven
```
...
software.amazon.lambdapowertools-logging-log4j2.6.0software.amazon.lambdapowertools-logging2.6.0
...
...
...
dev.aspectjaspectj-maven-plugin1.14111111software.amazon.lambdapowertools-loggingorg.aspectjaspectjtools1.9.22compile
...
```
```
...
software.amazon.lambdapowertools-logging-logback2.6.0software.amazon.lambdapowertools-logging2.6.0
...
...
...
dev.aspectjaspectj-maven-plugin1.14111111software.amazon.lambdapowertools-loggingorg.aspectjaspectjtools1.9.22compile
...
```
#### Gradle
```
plugins {
id 'java'
id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' // Not needed when using the functional approach
}
repositories {
mavenCentral()
}
dependencies {
aspect 'software.amazon.lambda:powertools-logging:2.6.0' // Not needed when using the functional approach
implementation 'software.amazon.lambda:powertools-logging-log4j:2.6.0'
}
sourceCompatibility = 11
targetCompatibility = 11
```
```
plugins {
id 'java'
id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' // Not needed when using the functional approach
}
repositories {
mavenCentral()
}
dependencies {
aspect 'software.amazon.lambda:powertools-logging:2.6.0' // Not needed when using the functional approach
implementation 'software.amazon.lambda:powertools-logging-logback:2.6.0'
}
sourceCompatibility = 11
targetCompatibility = 11
```
### Configuration
#### Main environment variables
The logging module requires two settings:
| Environment variable | Setting | Description | | --- | --- | --- | | `POWERTOOLS_LOG_LEVEL` | **Logging level** | Sets how verbose Logger should be. If not set, will use the [Logging configuration](#logging-configuration) | | `POWERTOOLS_SERVICE_NAME` | **Service** | Sets service key that will be included in all log statements (Default is `service_undefined`) |
Here is an example using AWS Serverless Application Model (SAM):
```
Resources:
PaymentFunction:
Type: AWS::Serverless::Function
Properties:
MemorySize: 512
Timeout: 20
Runtime: java17
Environment:
Variables:
POWERTOOLS_LOG_LEVEL: WARN
POWERTOOLS_SERVICE_NAME: payment
```
There are some other environment variables which can be set to modify Logging's settings at a global scope:
| Environment variable | Type | Description | | --- | --- | --- | | `POWERTOOLS_LOGGER_SAMPLE_RATE` | float | Configure the sampling rate at which `DEBUG` logs should be included. See [sampling rate](#sampling-debug-logs) | | `POWERTOOLS_LOGGER_LOG_EVENT` | boolean | Specify if the incoming Lambda event should be logged. See [Logging event](#logging-incoming-event) | | `POWERTOOLS_LOGGER_LOG_RESPONSE` | boolean | Specify if the Lambda response should be logged. See [logging response](#logging-handler-response) | | `POWERTOOLS_LOGGER_LOG_ERROR` | boolean | Specify if a Lambda uncaught exception should be logged. See [logging exception](#logging-handler-uncaught-exception) |
#### Logging configuration
Powertools for AWS Lambda (Java) simply extends the functionality of the underlying library you choose (*log4j2* or *logback*). You can leverage the standard configuration files (*log4j2.xml* or *logback.xml*):
With log4j2, we leverage the [`JsonTemplateLayout`](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html) to provide structured logging. A default template is provided in powertools ([*LambdaJsonLayout.json*](https://github.com/aws-powertools/powertools-lambda-java/blob/4444b4bce8eb1cc19880d1c1ef07188d97de9126/powertools-logging/powertools-logging-log4j/src/main/resources/LambdaJsonLayout.json)):
```
```
With logback, we leverage a custom [Encoder](https://logback.qos.ch/manual/encoders.html) to provide structured logging:
```
```
## Log level
Log level is generally configured in the `log4j2.xml` or `logback.xml`. But this level is static and needs a redeployment of the function to be changed. Powertools for AWS Lambda permits to change this level dynamically thanks to an environment variable `POWERTOOLS_LOG_LEVEL`.
We support the following log levels (SLF4J levels): `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`. If the level is set to `CRITICAL` (supported in log4j but not logback), we revert it back to `ERROR`. If the level is set to any other value, we set it to the default value (`INFO`).
### AWS Lambda Advanced Logging Controls (ALC)
When is it useful?
When you want to set a logging policy to drop informational or verbose logs for one or all AWS Lambda functions, regardless of runtime and logger used.
With [AWS Lambda Advanced Logging Controls (ALC)](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced), you can enforce a minimum log level that Lambda will accept from your application code.
When enabled, you should keep your own log level and ALC log level in sync to avoid data loss.
Here's a sequence diagram to demonstrate how ALC will drop both `INFO` and `DEBUG` logs emitted from `Logger`, when ALC log level is stricter than `Logger`.
```
sequenceDiagram
participant Lambda service
participant Lambda function
participant Application Logger
Note over Lambda service: AWS_LAMBDA_LOG_LEVEL="WARN"
Note over Application Logger: POWERTOOLS_LOG_LEVEL="DEBUG"
Lambda service->>Lambda function: Invoke (event)
Lambda function->>Lambda function: Calls handler
Lambda function->>Application Logger: logger.error("Something happened")
Lambda function-->>Application Logger: logger.debug("Something happened")
Lambda function-->>Application Logger: logger.info("Something happened")
Lambda service--xLambda service: DROP INFO and DEBUG logs
Lambda service->>CloudWatch Logs: Ingest error logs
```
### Priority of log level settings in Powertools for AWS Lambda
We prioritise log level settings in this order:
1. `AWS_LAMBDA_LOG_LEVEL` environment variable
1. `POWERTOOLS_LOG_LEVEL` environment variable
1. level defined in the `log4j2.xml` or `logback.xml` files
If you set `POWERTOOLS_LOG_LEVEL` lower than ALC, we will emit a warning informing you that your messages will be discarded by Lambda.
Note
With ALC enabled, we are unable to increase the minimum log level below the `AWS_LAMBDA_LOG_LEVEL` environment variable value, see [AWS Lambda service documentation](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-log-level) for more details.
## Basic Usage
You can use Powertools for AWS Lambda Logging with either the `@Logging` annotation or the functional API:
```
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.lambda.powertools.logging.Logging;
// ... other imports
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentFunction.class);
@Logging
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
LOGGER.info("Collecting payment");
// ...
LOGGER.debug("order={}, amount={}", order.getId(), order.getAmount());
// ...
}
}
```
```
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.lambda.powertools.logging.PowertoolsLogging;
// ... other imports
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentFunction.class);
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
return PowertoolsLogging.withLogging(context, () -> {
LOGGER.info("Collecting payment");
// ...
LOGGER.debug("order={}, amount={}", order.getId(), order.getAmount());
// ...
return new APIGatewayProxyResponseEvent().withStatusCode(200);
});
}
}
```
## Standard structured keys
Your logs will always include the following keys in your structured logging:
| Key | Type | Example | Description | | --- | --- | --- | --- | | **timestamp** | String | "2023-12-01T14:49:19.293Z" | Timestamp of actual log statement, by default uses default AWS Lambda timezone (UTC) | | **level** | String | "INFO" | Logging level (any level supported by *SLF4J* (i.e. `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`) | | **service** | String | "payment" | Service name defined, by default `service_undefined` | | **sampling_rate** | float | 0.1 | Debug logging sampling rate in percentage e.g. 10% in this case (logged if not 0) | | **message** | String | "Collecting payment" | Log statement value. Unserializable JSON values will be casted to string | | **xray_trace_id** | String | "1-5759e988-bd862e3fe1be46a994272793" | X-Ray Trace ID when [Tracing is enabled](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html) | | **error** | Map | `{ "name": "InvalidAmountException", "message": "Amount must be superior to 0", "stack": "at..." }` | Eventual exception (e.g. when doing `logger.error("Error", new InvalidAmountException("Amount must be superior to 0"));`) |
Note
If you emit a log message with a key that matches one of the [standard structured keys](#standard-structured-keys) or one of the [additional structured keys](#additional-structured-keys), the Logger will log a warning message and ignore the key.
## Additional structured keys
### Logging Lambda context information
The following keys will also be added to all your structured logs (unless [configured otherwise](#more-customization_1)):
| Key | Type | Example | Description | | --- | --- | --- | --- | | **cold_start** | Boolean | false | ColdStart value | | **function_name** | String | "example-PaymentFunction-1P1Z6B39FLU73" | Name of the function | | **function_version** | String | "12" | Version of the function | | **function_memory_size** | String | "512" | Memory configure for the function | | **function_arn** | String | "arn:aws:lambda:eu-west-1:012345678910:function:example-PaymentFunction-1P1Z6B39FLU73" | ARN of the function | | **function_request_id** | String | "899856cb-83d1-40d7-8611-9e78f15f32f4"" | AWS Request ID from lambda context |
### Logging additional keys
#### Logging a correlation ID
You can set a correlation ID using the `correlationIdPath` parameter by passing a [JMESPath expression](https://jmespath.org/tutorial.html), including our custom [JMESPath Functions](../../utilities/serialization/#built-in-functions).
```
public class AppCorrelationIdPath implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppCorrelationIdPath.class);
@Logging(correlationIdPath = "headers.my_request_id_header")
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
// ...
LOGGER.info("Collecting payment")
// ...
}
}
```
```
public class AppCorrelationIdPath implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppCorrelationIdPath.class);
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
return PowertoolsLogging.withLogging(context, "headers.my_request_id_header", input, () -> {
// ...
LOGGER.info("Collecting payment");
// ...
return new APIGatewayProxyResponseEvent().withStatusCode(200);
});
}
}
```
```
{
"headers": {
"my_request_id_header": "correlation_id_value"
}
}
```
```
{
"level": "INFO",
"message": "Collecting payment",
"timestamp": "2023-12-01T14:49:19.293Z",
"service": "payment",
"correlation_id": "correlation_id_value"
}
```
**Known correlation IDs**
To ease routine tasks like extracting correlation ID from popular event sources, we provide [built-in JMESPath expressions](#built-in-correlation-id-expressions).
```
import software.amazon.lambda.powertools.logging.CorrelationIdPaths;
public class AppCorrelationId implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppCorrelationId.class);
@Logging(correlationIdPath = CorrelationIdPaths.API_GATEWAY_REST)
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
// ...
LOGGER.info("Collecting payment")
// ...
}
}
```
```
import software.amazon.lambda.powertools.logging.CorrelationIdPaths;
public class AppCorrelationId implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppCorrelationId.class);
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
return PowertoolsLogging.withLogging(context, CorrelationIdPaths.API_GATEWAY_REST, input, () -> {
// ...
LOGGER.info("Collecting payment");
// ...
return new APIGatewayProxyResponseEvent().withStatusCode(200);
});
}
}
```
```
{
"requestContext": {
"requestId": "correlation_id_value"
}
}
```
```
{
"level": "INFO",
"message": "Collecting payment",
"timestamp": "2023-12-01T14:49:19.293Z",
"service": "payment",
"correlation_id": "correlation_id_value"
}
```
#### Custom keys
**Using StructuredArguments**
To append additional keys in your logs, you can use the `StructuredArguments` class:
```
import static software.amazon.lambda.powertools.logging.argument.StructuredArguments.entry;
import static software.amazon.lambda.powertools.logging.argument.StructuredArguments.entries;
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppLogResponse.class);
@Logging
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
// ...
LOGGER.info("Collecting payment", entry("orderId", order.getId()));
// ...
Map customKeys = new HashMap<>();
customKeys.put("paymentId", payment.getId());
customKeys.put("amount", payment.getAmount);
LOGGER.info("Payment successful", entries(customKeys));
}
}
```
```
{
"level": "INFO",
"message": "Collecting payment",
"service": "payment",
"timestamp": "2023-12-01T14:49:19.293Z",
"xray_trace_id": "1-6569f266-4b0c7f97280dcd8428d3c9b5",
"orderId": "41376"
}
...
{
"level": "INFO",
"message": "Payment successful",
"service": "payment",
"timestamp": "2023-12-01T14:49:20.118Z",
"xray_trace_id": "1-6569f266-4b0c7f97280dcd8428d3c9b5",
"orderId": "41376",
"paymentId": "3245",
"amount": 345.99
}
```
`StructuredArguments` provides several options:
- `entry` to add one key and value into the log structure. Note that value can be any object type.
- `entries` to add multiple keys and values (from a Map) into the log structure. Note that values can be any object type.
- `json` to add a key and raw json (string) as value into the log structure.
- `array` to add one key and multiple values into the log structure. Note that values can be any object type.
```
import static software.amazon.lambda.powertools.logging.argument.StructuredArguments.entry;
import static software.amazon.lambda.powertools.logging.argument.StructuredArguments.array;
public class OrderFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppLogResponse.class);
@Logging
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
// ...
LOGGER.info("Processing order", entry("order", order), array("products", productList));
// ...
}
}
```
```
{
"level": "INFO",
"message": "Processing order",
"service": "payment",
"timestamp": "2023-12-01T14:49:19.293Z",
"xray_trace_id": "1-6569f266-4b0c7f97280dcd8428d3c9b5",
"order": {
"orderId": 23542,
"amount": 459.99,
"date": "2023-12-01T14:49:19.018Z",
"customerId": 328496
},
"products": [
{
"productId": 764330,
"name": "product1",
"quantity": 1,
"price": 300
},
{
"productId": 798034,
"name": "product42",
"quantity": 1,
"price": 159.99
}
]
}
```
Use arguments without log placeholders
As shown in the example above, you can use arguments (with `StructuredArguments`) without placeholders (`{}`) in the message. If you add the placeholders, the arguments will be logged both as an additional field and also as a string in the log message, using the `toString()` method.
```
LOGGER.info("Processing {}", entry("order", order));
```
```
public class Order {
// ...
@Override
public String toString() {
return "Order{" +
"orderId=" + id +
", amount=" + amount +
", date='" + date + '\'' +
", customerId=" + customerId +
'}';
}
}
```
```
{
"level": "INFO",
"message": "Processing order=Order{orderId=23542, amount=459.99, date='2023-12-01T14:49:19.018Z', customerId=328496}",
"service": "payment",
"timestamp": "2023-12-01T14:49:19.293Z",
"xray_trace_id": "1-6569f266-4b0c7f97280dcd8428d3c9b5",
"order": {
"orderId": 23542,
"amount": 459.99,
"date": "2023-12-01T14:49:19.018Z",
"customerId": 328496
}
}
```
You can also combine structured arguments with non structured ones. For example:
```
LOGGER.info("Processing order {}", order.getOrderId(), entry("order", order));
```
```
{
"level": "INFO",
"message": "Processing order 23542",
"service": "payment",
"timestamp": "2023-12-01T14:49:19.293Z",
"xray_trace_id": "1-6569f266-4b0c7f97280dcd8428d3c9b5",
"order": {
"orderId": 23542,
"amount": 459.99,
"date": "2023-12-01T14:49:19.018Z",
"customerId": 328496
}
}
```
Do not use reserved keys in `StructuredArguments`
If the key name of your structured argument matches any of the [standard structured keys](#standard-structured-keys) or any of the [additional structured keys](#additional-structured-keys), the Logger will log a warning message and ignore the key. This is to protect you from accidentally overwriting reserved keys such as the log level or Lambda context information.
**Using MDC**
Mapped Diagnostic Context (MDC) is essentially a Key-Value store. It is supported by the [SLF4J API](https://www.slf4j.org/manual.html#mdc), [logback](https://logback.qos.ch/manual/mdc.html) and log4j (known as [ThreadContext](https://logging.apache.org/log4j/2.x/manual/thread-context.html)). You can use the following standard:
`MDC.put("key", "value");`
Custom keys stored in the MDC are persisted across warm invocations
Always set additional keys as part of your handler method to ensure they have the latest value, or explicitly clear them with [`clearState=true`](#clearing-state).
Do not add reserved keys to MDC
Avoid adding any of the keys listed in [standard structured keys](#standard-structured-keys) and [additional structured keys](#additional-structured-keys) to your MDC. This may cause unindented behavior and will overwrite the context set by the Logger. Unlike with `StructuredArguments`, the Logger will **not** ignore reserved keys set via MDC.
### Removing additional keys
You can remove additional keys added with the MDC using `MDC.remove("key")`.
#### Clearing state
Logger is commonly initialized in the global scope. Due to [Lambda Execution Context reuse](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html), this means that custom keys, added with the MDC can be persisted across invocations. You can clear state using `clearState=true` on the `@Logging` annotation, or use the functional API which handles cleanup automatically.
```
public class CreditCardFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(CreditCardFunction.class);
@Logging(clearState = true)
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
// ...
MDC.put("cardNumber", card.getId());
LOGGER.info("Updating card information");
// ...
}
}
```
```
{
"level": "INFO",
"message": "Updating card information",
"service": "card",
"timestamp": "2023-12-01T14:49:19.293Z",
"xray_trace_id": "1-6569f266-4b0c7f97280dcd8428d3c9b5",
"cardNumber": "6818 8419 9395 5322"
}
```
```
{
"level": "INFO",
"message": "Updating card information",
"service": "card",
"timestamp": "2023-12-01T14:49:20.213Z",
"xray_trace_id": "2-7a518f43-5e9d2b1f6cfd5e8b3a4e1f9c",
"cardNumber": "7201 6897 6685 3285"
}
```
`clearState` is based on `MDC.clear()`. State clearing is automatically done at the end of the execution of the handler if set to `true`.
Tip
When using the functional API with `PowertoolsLogging.withLogging()`, state is automatically cleared at the end of execution, so you don't need to manage it manually.
## Logging incoming event
When debugging in non-production environments, you can log the incoming event using the `@Logging` annotation with `logEvent` param, via `POWERTOOLS_LOGGER_LOG_EVENT` env var, or manually with the functional API.
Warning
This is disabled by default to prevent sensitive info being logged.
```
public class AppLogEvent implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppLogEvent.class);
@Logging(logEvent = true)
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
// ...
}
}
```
```
import static software.amazon.lambda.powertools.logging.argument.StructuredArguments.entry;
public class AppLogEvent implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppLogEvent.class);
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
return PowertoolsLogging.withLogging(context, () -> {
LOGGER.info("Handler Event", entry("event", input));
// ...
return new APIGatewayProxyResponseEvent().withStatusCode(200);
});
}
}
```
Note
If you use this on a RequestStreamHandler, the SDK must duplicate input streams in order to log them when used together with the `@Logging` annotation.
## Logging handler response
When debugging in non-production environments, you can log the response using the `@Logging` annotation with `logResponse` param, via `POWERTOOLS_LOGGER_LOG_RESPONSE` env var, or manually with the functional API.
Warning
This is disabled by default to prevent sensitive info being logged.
```
public class AppLogResponse implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppLogResponse.class);
@Logging(logResponse = true)
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
// ...
}
}
```
```
import static software.amazon.lambda.powertools.logging.argument.StructuredArguments.entry;
public class AppLogResponse implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppLogResponse.class);
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
return PowertoolsLogging.withLogging(context, () -> {
// ...
APIGatewayProxyResponseEvent response = new APIGatewayProxyResponseEvent().withStatusCode(200);
LOGGER.info("Handler Response", entry("response", response));
return response;
});
}
}
```
Note
If you use this on a RequestStreamHandler, Powertools must duplicate output streams in order to log them when used together with the `@Logging` annotation.
## Logging handler uncaught exception
By default, AWS Lambda logs any uncaught exception that might happen in the handler. However, this log is not structured and does not contain any additional context. When using the `@Logging` annotation, you can enable structured exception logging with `logError` param or via `POWERTOOLS_LOGGER_LOG_ERROR` env var.
Warning
This is disabled by default to prevent double logging.
Note
This feature is only available when using the `@Logging` annotation. When using the functional API, you must catch and log exceptions manually using try-catch blocks.
```
public class AppLogError implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppLogError.class);
@Logging(logError = true)
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
// ...
}
}
```
```
import org.slf4j.MarkerFactory;
public class AppLogError implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AppLogError.class);
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
return PowertoolsLogging.withLogging(context, () -> {
try {
// ...
return new APIGatewayProxyResponseEvent().withStatusCode(200);
} catch (Exception e) {
LOGGER.error(MarkerFactory.getMarker("FATAL"), "Exception in Lambda Handler", e);
throw e;
}
});
}
}
```
## Advanced
### Buffering logs
Log buffering enables you to buffer logs for a specific request or invocation. Enable log buffering by configuring the `BufferingAppender` in your logging configuration. You can buffer logs at the `WARNING`, `INFO` or `DEBUG` level, and flush them automatically on error or manually as needed.
This is useful when you want to reduce the number of log messages emitted while still having detailed logs when needed, such as when troubleshooting issues.
```
```
```
20480DEBUGtrue
```
```
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.lambda.powertools.logging.Logging;
// ... other imports
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentFunction.class);
@Logging
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
LOGGER.debug("a debug log"); // this is buffered
LOGGER.info("an info log"); // this is not buffered
// do stuff
// Buffer is automatically cleared at the end of the method by @Logging annotation
return new APIGatewayProxyResponseEvent().withStatusCode(200);
}
}
```
#### Configuring the buffer
When configuring log buffering, you have options to fine-tune how logs are captured, stored, and emitted. You can configure the following parameters in the `BufferingAppender` configuration:
| Parameter | Description | Configuration | | --- | --- | --- | | `maxBytes` | Maximum size of the log buffer in bytes | `int` (default: 20480 bytes) | | `bufferAtVerbosity` | Minimum log level to buffer | `DEBUG` (default), `INFO`, `WARNING` | | `flushOnErrorLog` | Automatically flush buffer when `ERROR` or `FATAL` level logs are emitted | `true` (default), `false` |
Logger Level Configuration
To use log buffering effectively, you must set your logger levels to the same level as `bufferAtVerbosity` or more verbose for the logging framework to capture and forward logs to the `BufferingAppender`. For example, if you want to buffer `DEBUG` level logs and emit `INFO`+ level logs directly, you must:
- Set your logger levels to `DEBUG` in your log4j2.xml or logback.xml configuration
- Set `POWERTOOLS_LOG_LEVEL=DEBUG` if using the environment variable (see [Log level](#log-level) section for more details)
If you want to sample `INFO` and `WARNING` logs but not `DEBUG` logs, set your log level to `INFO` and `bufferAtVerbosity` to `WARNING`. This allows you to define the lower and upper bounds for buffering. All logs with a more severe level than `bufferAtVerbosity` will be emitted directly.
```
```
```
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentFunction.class);
@Logging
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
LOGGER.warn("a warning log"); // this is buffered
LOGGER.info("an info log"); // this is buffered
LOGGER.debug("a debug log"); // this is buffered
// do stuff
// Buffer is automatically cleared at the end of the method by @Logging annotation
return new APIGatewayProxyResponseEvent().withStatusCode(200);
}
}
```
```
```
```
import software.amazon.lambda.powertools.logging.PowertoolsLogging;
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentFunction.class);
@Logging
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
LOGGER.debug("a debug log"); // this is buffered
// do stuff
try {
throw new RuntimeException("Something went wrong");
} catch (RuntimeException error) {
LOGGER.error("An error occurred", error); // Logs won't be flushed here
}
// Manually flush buffered logs
PowertoolsLogging.flushBuffer();
return new APIGatewayProxyResponseEvent().withStatusCode(200);
}
}
```
Disabling `flushOnErrorLog` will not flush the buffer when logging an error. This is useful when you want to control when the buffer is flushed by calling the flush method manually.
#### Manual buffer control
You can manually control the log buffer using the `PowertoolsLogging` utility class, which provides a backend-independent API that works with both Log4j2 and Logback:
```
import software.amazon.lambda.powertools.logging.PowertoolsLogging;
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentFunction.class);
@Logging
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
LOGGER.debug("Processing payment"); // this is buffered
LOGGER.info("Payment validation complete"); // this is buffered
// Manually flush all buffered logs
PowertoolsLogging.flushBuffer();
return new APIGatewayProxyResponseEvent().withStatusCode(200);
}
}
```
```
import software.amazon.lambda.powertools.logging.PowertoolsLogging;
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentFunction.class);
@Logging
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
LOGGER.debug("Processing payment"); // this is buffered
LOGGER.info("Payment validation complete"); // this is buffered
// Manually clear buffered logs without outputting them
PowertoolsLogging.clearBuffer();
return new APIGatewayProxyResponseEvent().withStatusCode(200);
}
}
```
**Available methods:**
- `PowertoolsLogging.flushBuffer()` - Outputs all buffered logs and clears the buffer
- `PowertoolsLogging.clearBuffer()` - Discards all buffered logs without outputting them
#### Flushing on exceptions
Use the `@Logging` annotation to automatically flush buffered logs when an uncaught exception is raised in your Lambda function. This is enabled by default (`flushBufferOnUncaughtError = true`), but you can explicitly configure it if needed.
Warning
This feature is only available when using the `@Logging` annotation. When using the functional API, you must manually flush the buffer in exception handlers.
```
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentFunction.class);
@Logging(flushBufferOnUncaughtError = true)
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
LOGGER.debug("a debug log"); // this is buffered
// do stuff
throw new RuntimeException("Something went wrong"); // Logs will be flushed here
}
}
```
```
import software.amazon.lambda.powertools.logging.PowertoolsLogging;
public class PaymentFunction implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentFunction.class);
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
return PowertoolsLogging.withLogging(context, () -> {
try {
LOGGER.debug("a debug log"); // this is buffered
// do stuff
throw new RuntimeException("Something went wrong");
} catch (Exception e) {
PowertoolsLogging.flushBuffer(); // Manually flush buffered logs
throw e;
}
});
}
}
```
#### Buffering workflows
##### Manual flush
```
sequenceDiagram
participant Client
participant Lambda
participant Logger
participant CloudWatch
Client->>Lambda: Invoke Lambda
Lambda->>Logger: Initialize with DEBUG level buffering
Logger-->>Lambda: Logger buffer ready
Lambda->>Logger: logger.debug("First debug log")
Logger-->>Logger: Buffer first debug log
Lambda->>Logger: logger.info("Info log")
Logger->>CloudWatch: Directly log info message
Lambda->>Logger: logger.debug("Second debug log")
Logger-->>Logger: Buffer second debug log
Lambda->>Logger: Manual flush call
Logger->>CloudWatch: Emit buffered logs to stdout
Lambda->>Client: Return execution result
```
*Flushing buffer manually*
##### Flushing when logging an error
```
sequenceDiagram
participant Client
participant Lambda
participant Logger
participant CloudWatch
Client->>Lambda: Invoke Lambda
Lambda->>Logger: Initialize with DEBUG level buffering
Logger-->>Lambda: Logger buffer ready
Lambda->>Logger: logger.debug("First log")
Logger-->>Logger: Buffer first debug log
Lambda->>Logger: logger.debug("Second log")
Logger-->>Logger: Buffer second debug log
Lambda->>Logger: logger.debug("Third log")
Logger-->>Logger: Buffer third debug log
Lambda->>Lambda: Exception occurs
Lambda->>Logger: logger.error("Error details")
Logger->>CloudWatch: Emit error log
Logger->>CloudWatch: Emit buffered debug logs
Lambda->>Client: Raise exception
```
*Flushing buffer when an error happens*
##### Flushing on exception
This works when using the `@Logging` annotation which automatically clears the buffer at the end of method execution.
```
sequenceDiagram
participant Client
participant Lambda
participant Logger
participant CloudWatch
Client->>Lambda: Invoke Lambda
Lambda->>Logger: Using @Logging annotation
Logger-->>Lambda: Logger context injected
Lambda->>Logger: logger.debug("First log")
Logger-->>Logger: Buffer first debug log
Lambda->>Logger: logger.debug("Second log")
Logger-->>Logger: Buffer second debug log
Lambda->>Lambda: Uncaught Exception
Lambda->>CloudWatch: Automatically emit buffered debug logs
Lambda->>Client: Raise uncaught exception
```
*Flushing buffer when an uncaught exception happens*
#### Buffering FAQs
1. **Does the buffer persist across Lambda invocations?** 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.
1. **Are my logs buffered during cold starts (INIT phase)?** No, we never buffer logs during cold starts. This is because we want to ensure that logs emitted during this phase are always available for debugging and monitoring purposes. The buffer is only used during the execution of the Lambda function.
1. **How can I prevent log buffering from consuming excessive memory?** You can limit the size of the buffer by setting the `maxBytes` option in the `BufferingAppender` configuration. This will ensure that the buffer does not grow indefinitely.
1. **What happens if the log buffer reaches its maximum size?** 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.
1. **How is the log size of a log line calculated?** The log size is calculated based on the size of the log line in bytes. This includes the size of the log message, any exception (if present), the log line location, additional keys, and the timestamp.
1. **What timestamp is used when I flush the logs?** The timestamp is the original time when the log record was created. If you create a log record at 11:00:10 and flush it at 11:00:25, the log line will retain its original timestamp of 11:00:10.
1. **What happens if I try to add a log line that is bigger than max buffer size?** The log will be emitted directly to standard output and not buffered. When this happens, we emit a warning to indicate that the log line was too big to be buffered.
1. **What happens if Lambda times out without flushing the buffer?** Logs that are still in the buffer will be lost.
1. **How does the `BufferingAppender` work with different appenders?** The `BufferingAppender` is designed to wrap arbitrary appenders, providing maximum flexibility. You can wrap console appenders, file appenders, or any custom appenders with buffering functionality.
## Sampling debug logs
You can dynamically set a percentage of your logs to`DEBUG` level to be included in the logger output, regardless of configured log level, using the`POWERTOOLS_LOGGER_SAMPLE_RATE` environment variable, via `samplingRate` attribute on the `@Logging` annotation, or as a parameter in the functional API.
Info
Configuration on environment variable is given precedence over sampling rate configuration, provided it's in valid value range.
```
public class App implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
@Logging(samplingRate = 0.5)
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
// will eventually be logged based on the sampling rate
LOGGER.debug("Handle payment");
}
}
```
```
public class App implements RequestHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
return PowertoolsLogging.withLogging(context, 0.5, () -> {
// will eventually be logged based on the sampling rate
LOGGER.debug("Handle payment");
return new APIGatewayProxyResponseEvent().withStatusCode(200);
});
}
}
```
```
Resources:
PaymentFunction:
Type: AWS::Serverless::Function
Properties:
...
Environment:
Variables:
POWERTOOLS_LOGGER_SAMPLE_RATE: 0.5
```
## Built-in Correlation ID expressions
You can use any of the following built-in JMESPath expressions with the `@Logging` annotation or the functional API:
Note: Any object key named with `-` must be escaped
For example, **`request.headers."x-amzn-trace-id"`**.
| Name | Expression | Description | | --- | --- | --- | | **API_GATEWAY_REST** | `"requestContext.requestId"` | API Gateway REST API request ID | | **API_GATEWAY_HTTP** | `"requestContext.requestId"` | API Gateway HTTP API request ID | | **APPSYNC_RESOLVER** | `request.headers."x-amzn-trace-id"` | AppSync X-Ray Trace ID | | **APPLICATION_LOAD_BALANCER** | `headers."x-amzn-trace-id"` | ALB X-Ray Trace ID | | **EVENT_BRIDGE** | `"id"` | EventBridge Event ID |
## Customising fields in logs
Powertools for AWS Lambda comes with default json structure ([standard fields](#standard-structured-keys) & [lambda context fields](#logging-lambda-context-information)).
You can go further and customize which fields you want to keep in your logs or not. The configuration varies according to the underlying logging library.
### Log4j2 configuration
Log4j2 configuration is done in *log4j2.xml* and leverages `JsonTemplateLayout`:
```
```
The `JsonTemplateLayout` is automatically configured with the provided template:
LambdaJsonLayout.json
```
{
"level": {
"$resolver": "level",
"field": "name"
},
"message": {
"$resolver": "message"
},
"error": {
"message": {
"$resolver": "exception",
"field": "message"
},
"name": {
"$resolver": "exception",
"field": "className"
},
"stack": {
"$resolver": "exception",
"field": "stackTrace",
"stackTrace": {
"stringified": true
}
}
},
"cold_start": {
"$resolver": "powertools",
"field": "cold_start"
},
"function_arn": {
"$resolver": "powertools",
"field": "function_arn"
},
"function_memory_size": {
"$resolver": "powertools",
"field": "function_memory_size"
},
"function_name": {
"$resolver": "powertools",
"field": "function_name"
},
"function_request_id": {
"$resolver": "powertools",
"field": "function_request_id"
},
"function_version": {
"$resolver": "powertools",
"field": "function_version"
},
"sampling_rate": {
"$resolver": "powertools",
"field": "sampling_rate"
},
"service": {
"$resolver": "powertools",
"field": "service"
},
"timestamp": {
"$resolver": "timestamp",
"pattern": {
"format": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
}
},
"xray_trace_id": {
"$resolver": "powertools",
"field": "xray_trace_id"
},
"correlation_id": {
"$resolver": "powertools",
"field": "correlation_id"
},
"": {
"$resolver": "powertools"
}
}
```
You can create your own template and leverage the [PowertoolsResolver](https://github.com/aws-powertools/powertools-lambda-java/tree/v2/powertools-logging/powertools-logging-log4j/src/main/java/org/apache/logging/log4j/layout/template/json/resolver/PowertoolsResolver.java) and any other resolver to log the desired fields with the desired format. Some examples of customization are given below:
#### Customising date format
Utility by default emits `timestamp` field in the logs in format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'` and in system default timezone. If you need to customize format and timezone, you can update your template.json or by configuring `log4j2.component.properties` as shown in examples below:
```
{
"timestamp": {
"$resolver": "timestamp",
"pattern": {
"format": "yyyy-MM-dd HH:mm:ss",
"timeZone": "Europe/Paris",
}
},
}
```
```
log4j.layout.jsonTemplate.timestampFormatPattern=yyyy-MM-dd'T'HH:mm:ss.SSSZz
log4j.layout.jsonTemplate.timeZone=Europe/Oslo
```
See [`TimestampResolver` documentation](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#event-template-resolver-timestamp) for more details.
Lambda Advanced Logging Controls date format
When using the Lambda ALC, you must have a date format compatible with the [RFC3339](https://www.rfc-editor.org/rfc/rfc3339)
#### More customization
You can also customize how [exceptions are logged](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#event-template-resolver-exception), and much more. See the [JSON Layout template documentation](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html) for more details.
### Logback configuration
Logback configuration is done in *logback.xml* and the `LambdaJsonEncoder`:
```
```
The `LambdaJsonEncoder` can be customized in different ways:
#### Customising date format
Utility by default emits `timestamp` field in the logs in format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'` and in system default timezone. If you need to customize format and timezone, you can change use the following:
```
yyyy-MM-dd HH:mm:ssEurope/Paris
```
#### More customization
- You can use a standard `ThrowableHandlingConverter` to customize the exception format (default is no converter). Example:
```
30204820sun\.reflect\..*\.invoke.*net\.sf\.cglib\.proxy\.MethodProxy\.invoketruetrue
```
- You can choose to add information about threads (default is `false`):
```
true
```
- You can even choose to remove Powertools information from the logs like function name, arn:
```
false
```
## Elastic Common Schema (ECS) Support
Utility also supports [Elastic Common Schema(ECS)](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html) format. The field emitted in logs will follow specs from [ECS](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html) together with field captured by utility as mentioned [above](#standard-structured-keys).
### Log4j2 configuration
Use `LambdaEcsLayout.json` as `eventTemplateUri` when configuring `JsonTemplateLayout`.
```
```
### Logback configuration
Use the `LambdaEcsEncoder` rather than the `LambdaJsonEncoder` when configuring the appender:
```
```
Metrics creates custom metrics asynchronously by logging metrics to standard output following [Amazon CloudWatch Embedded Metric Format (EMF)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format.html).
These metrics can be visualized through [Amazon CloudWatch Console](https://aws.amazon.com/cloudwatch/).
## Key features
- Aggregate up to 100 metrics using a single [CloudWatch EMF](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html) object (large JSON blob)
- Validating your metrics against common metric definitions mistakes (for example, metric unit, values, max dimensions, max metrics)
- Metrics are created asynchronously by the CloudWatch service. You do not need any custom stacks, and there is no impact to Lambda function latency
- Support for creating one off metrics with different dimensions
- GraalVM support
## Terminologies
If you're new to Amazon CloudWatch, there are some terminologies you must be aware of before using this utility:
- **Namespace**. It's the highest level container that will group multiple metrics from multiple services for a given application, for example `ServerlessAirline`.
- **Dimensions**. Metrics metadata in key-value format. They help you slice and dice metrics visualization, for example `ColdStart` metric by `service`.
- **Metric**. It's the name of the metric, for example: `SuccessfulBooking` or `UpdatedBooking`.
- **Unit**. It's a value representing the unit of measure for the corresponding metric, for example: `Count` or `Seconds`.
- **Resolution**. It's a value representing the storage resolution for the corresponding metric. Metrics can be either `Standard` or `High` resolution. Read more about CloudWatch Periods [here](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Resolution_definition).
Visit the AWS documentation for a complete explanation for [Amazon CloudWatch concepts](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html).
Metric terminology, visually explained
## Install
```
...
software.amazon.lambdapowertools-metrics2.6.0
...
...
...
dev.aspectjaspectj-maven-plugin1.14111111software.amazon.lambdapowertools-metricsorg.aspectjaspectjtools1.9.22compile
...
```
```
plugins {
id 'java'
id 'io.freefair.aspectj.post-compile-weaving' version '8.1.0' // Not needed when using the functional approach
}
repositories {
mavenCentral()
}
dependencies {
aspect 'software.amazon.lambda:powertools-metrics:2.6.0' // Not needed when using the functional approach
implementation 'software.amazon.lambda:powertools-metrics:2.6.0' // Use this instead of 'aspect' when using the functional approach
}
sourceCompatibility = 11
targetCompatibility = 11
```
## Getting started
Metrics has three global settings that will be used across all metrics emitted. Use your application or main service as the metric namespace to easily group all metrics:
| Setting | Description | Environment variable | Decorator parameter | | --- | --- | --- | --- | | **Metric namespace** | Logical container where all metrics will be placed e.g. `ServerlessAirline` | `POWERTOOLS_METRICS_NAMESPACE` | `namespace` | | **Service** | Optionally, sets **service** metric dimension across all metrics e.g. `payment` | `POWERTOOLS_SERVICE_NAME` | `service` | | **Function name** | Function name used as dimension for the cold start metric | `POWERTOOLS_METRICS_FUNCTION_NAME` | `functionName` | | **Disable Metrics** | Optionally, disables all metrics flushing | `POWERTOOLS_METRICS_DISABLED` | N/A |
Use your application or main service as the metric namespace to easily group all metrics
`POWERTOOLS_METRICS_DISABLED` will not disable default metrics created by AWS services.
### Order of Precedence of `Metrics` configuration
The `Metrics` Singleton can be configured by three different interfaces. The following order of precedence applies:
1. `@FlushMetrics` annotation
1. `MetricsBuilder` using Builder pattern (see [Advanced section](#usage-without-flushmetrics-annotation))
1. Environment variables (recommended)
For most use-cases, we recommend using Environment variables and only overwrite settings in code where needed using either the `@FlushMetrics` annotation or `MetricsBuilder` if the annotation cannot be used.
```
import software.amazon.lambda.powertools.metrics.FlushMetrics;
import software.amazon.lambda.powertools.metrics.MetricsFactory;
public class MetricsEnabledHandler implements RequestHandler