Skip to content

Commit e7757c7

Browse files
authored
Merge pull request #1525 from aws-powertools/chore/main-into-v2
chore: Periodic merge of main into v2
2 parents 3afb1d2 + 53e55b6 commit e7757c7

File tree

37 files changed

+781
-88
lines changed

37 files changed

+781
-88
lines changed

.github/workflows/pr_build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
strategy:
5050
max-parallel: 5
5151
matrix:
52-
java: [8, 11, 17, 21, 15, 16, 18, 19, 20]
52+
java: [8, 11, 17, 21]
5353
name: Java ${{ matrix.java }}
5454
env:
5555
JAVA: ${{ matrix.java }}

.github/workflows/run-e2e-tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ jobs:
3333
e2e:
3434
runs-on: ubuntu-latest
3535
strategy:
36-
max-parallel: 3
36+
max-parallel: 4
3737
matrix:
38-
java: [ 8, 11, 17 ]
38+
java: [ 8, 11, 17, 21 ]
3939
name: End-to-end tests java${{ matrix.java }}
4040
env:
41-
JAVA_VERSION: ${{ matrix.java }}
4241
AWS_DEFAULT_REGION: eu-west-1
42+
JAVA_VERSION: ${{ matrix.java }}
4343
permissions:
4444
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
4545
contents: read

CHANGELOG.md

+31
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,37 @@ This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) fo
88

99
## [Unreleased]
1010

11+
## [1.18.0] - 2023-11-16
12+
13+
### Added
14+
15+
* feat: add support for [Lambda Advanced Logging Controls (ALC)](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced) (#1514) by @jeromevdl
16+
* feat: Add support for POWERTOOLS_LOGGER_LOG_EVENT (#1510) by @AlexeySoshin
17+
18+
### Maintenance
19+
20+
* fix: json schema 403 error (#1457) by @jeromevdl
21+
* fix: array jmespath fail in idempotency module (#1420) by @jeromevdl
22+
* chore: java21 support in our build (#1488) by @jeromevdl
23+
* chore: Addition of Warn Message If Invalid Annotation Key While Tracing #1511 (#1512) by @jdoherty
24+
* fix: null namespace should fallback to default namespace (#1506) by @jeromevdl
25+
* fix: get trace id from system property when env var is not set (#1503) by @mriccia
26+
* chore: artifacts size on good branches (#1493) by @jeromevdl
27+
* fix: enforce jackson databind version (#1472) by @jeromevdl
28+
* chore: add missing projects and improve workflow (#1487) by @jeromevdl
29+
* chore: Reporting size of the jars in GitHub comments (#1196) by @jeromevdl
30+
* Deps: Bump third party dependencies to the latest versions.
31+
32+
### Documentation
33+
34+
* docs(customer-reference): add Vertex Pharmaceuticals as a customer reference (#1486) by @scottgerring
35+
* docs: Adding Kotlin example. (#1454) by @jasoniharris
36+
* docs: Terraform example (#1478) by @skal111
37+
* docs: Add Serveless Framework example (#1363) by @AlexeySoshin
38+
* docs: Fix link to SQS large message migration guide (#1422) by @scottgerring
39+
* docs(logging): correct log example keys (#1411) by @walmsles
40+
* docs: Update gradle configuration readme (#1359) by @scottgerring
41+
1142
## [1.17.0] - 2023-08-21
1243

1344
### Added

CONTRIBUTING.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ We strongly recommend installing the CheckStyle-IDEA plugin and apply the provid
5555
2. After installing the plugin, open the preferences (`⌘,` on macOS, or `Ctrl+Alt+S` on Windows/Linux) and search for _Code Style_. Click on the gear icon near the scheme and import checkstyle configuration. Click on "Apply" and "OK".
5656
![](docs/media/intellij_checkstyle_1.png)
5757

58-
3. Select the code you've created (module, package, class) and reformat code: `⌘⌥L` (macOS), or `Ctrl+Alt+L` (Windows/Linux):
59-
![](docs/media/intellij_checkstyle_2.png)
58+
3. Select the code you've created (module, package, class) and reformat code: `⌘⌥L` (macOS), or `Ctrl+Alt+L` (Windows/Linux).
6059

6160
4. Apply the reformat, optimize imports, rearrange and cleanup to your code and only to java files:
6261
![](docs/media/intellij_checkstyle_3.png)

README.md

+33-6
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ Powertools for AWS Lambda (Java) is a developer toolkit to implement Serverless
1111
1212
**[📜Documentation](https://docs.powertools.aws.dev/lambda-java/)** | **[Feature request](https://github.com/aws-powertools/powertools-lambda-java/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=)** | **[🐛Bug Report](https://github.com/aws-powertools/powertools-lambda-java/issues/new?assignees=&labels=bug%2C+triage&template=bug_report.md&title=)** | **[Detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-aws-lambda-powertools-java/)**
1313

14-
### Installation
14+
## Installation
1515

1616
Powertools for AWS Lambda (Java) is available in Maven Central. You can use your favourite dependency management tool to install it
1717

18-
#### Maven:
18+
### Maven:
1919
```xml
2020
<dependencies>
2121
...
2222
<dependency>
2323
<groupId>software.amazon.lambda</groupId>
2424
<artifactId>powertools-tracing</artifactId>
25-
<version>1.17.0</version>
25+
<version>1.18.0</version>
2626
</dependency>
2727
<dependency>
2828
<groupId>software.amazon.lambda</groupId>
2929
<artifactId>powertools-logging</artifactId>
30-
<version>1.17.0</version>
30+
<version>1.18.0</version>
3131
</dependency>
3232
<dependency>
3333
<groupId>software.amazon.lambda</groupId>
3434
<artifactId>powertools-metrics</artifactId>
35-
<version>1.17.0</version>
35+
<version>1.18.0</version>
3636
</dependency>
3737
...
3838
</dependencies>
@@ -190,9 +190,36 @@ Next, configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lam
190190
```
191191
</details>
192192

193+
### Java Compatibility
194+
Powertools for AWS Lambda (Java) supports all Java version from 8 up to 21 as well as the
195+
[corresponding Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html).
196+
For the modules that provide annotations, Powertools for AWS Lambda (Java) leverages the **aspectj** library.
197+
You may need to add the good version of `aspectjrt` to your dependencies based on the JDK used for building your function:
198+
199+
```xml
200+
<dependency>
201+
<groupId>org.aspectj</groupId>
202+
<artifactId>aspectjrt</artifactId>
203+
<version>1.9.??</version>
204+
</dependency>
205+
```
206+
207+
<details>
208+
<summary><b>JDK - aspectj dependency matrix</b></summary>
209+
210+
| JDK version | aspectj version |
211+
|-------------|-----------------|
212+
| `1.8` | `1.9.7` |
213+
| `11-17` | `1.9.20.1` |
214+
| `21` | `1.9.21` |
215+
216+
More info [here](https://github.com/aws-powertools/powertools-lambda-java/pull/1519/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R191).
217+
218+
</details>
219+
193220
## Examples
194221

195-
See the latest release of the **[examples](https://github.com/aws-powertools/powertools-lambda-java/tree/v1.17.0/examples)** for example projects showcasing usage of different utilities.
222+
See the latest release of the **[examples](https://github.com/aws-powertools/powertools-lambda-java/tree/v1.18.0/examples)** for example projects showcasing usage of different utilities.
196223

197224
Have a demo project to contribute which showcase usage of different utilities from powertools? We are happy to accept it [here](CONTRIBUTING.md#security-issue-notifications).
198225

docs/core/logging.md

+50-4
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,7 @@ Key | Type | Example | Description
217217

218218
## Capturing context Lambda info
219219

220-
You can enrich your structured logs with key Lambda context information via `logEvent` annotation parameter.
221-
You can also explicitly log any incoming event using `logEvent` param. Refer [Override default object mapper](#override-default-object-mapper)
222-
to customise what is logged.
220+
When debugging in non-production environments, you can instruct Logger to log the incoming event with `@Logger(logEvent = true)` or via `POWERTOOLS_LOGGER_LOG_EVENT=true` environment variable.
223221

224222
!!! warning
225223
Log event is disabled by default to prevent sensitive info being logged.
@@ -265,7 +263,7 @@ to customise what is logged.
265263
}
266264
```
267265

268-
### Customising fields in logs
266+
### Customising fields in logs
269267

270268
- Utility by default emits `timestamp` field in the logs in format `yyyy-MM-dd'T'HH:mm:ss.SSSZz` and in system default timezone.
271269
If you need to customize format and timezone, you can do so by configuring `log4j2.component.properties` and configuring properties as shown in example below:
@@ -598,6 +596,54 @@ via `samplingRate` attribute on annotation.
598596
POWERTOOLS_LOGGER_SAMPLE_RATE: 0.5
599597
```
600598

599+
## AWS Lambda Advanced Logging Controls (ALC)
600+
601+
!!!question "When is it useful?"
602+
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.
603+
604+
<!-- markdownlint-disable MD013 -->
605+
With [AWS Lambda Advanced Logging Controls (ALC)](https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html#monitoring-cloudwatchlogs-advanced){target="_blank"}, you can enforce a minimum log level that Lambda will accept from your application code.
606+
607+
When enabled, you should keep `Logger` and ALC log level in sync to avoid data loss.
608+
609+
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`.
610+
<!-- markdownlint-enable MD013 -->
611+
612+
```mermaid
613+
sequenceDiagram
614+
participant Lambda service
615+
participant Lambda function
616+
participant Application Logger
617+
618+
Note over Lambda service: AWS_LAMBDA_LOG_LEVEL="WARN"
619+
Note over Application Logger: POWERTOOLS_LOG_LEVEL="DEBUG"
620+
621+
Lambda service->>Lambda function: Invoke (event)
622+
Lambda function->>Lambda function: Calls handler
623+
Lambda function->>Application Logger: logger.error("Something happened")
624+
Lambda function-->>Application Logger: logger.debug("Something happened")
625+
Lambda function-->>Application Logger: logger.info("Something happened")
626+
Lambda service--xLambda service: DROP INFO and DEBUG logs
627+
Lambda service->>CloudWatch Logs: Ingest error logs
628+
```
629+
630+
### Priority of log level settings in Powertools for AWS Lambda
631+
632+
We prioritise log level settings in this order:
633+
634+
1. `AWS_LAMBDA_LOG_LEVEL` environment variable
635+
2. `POWERTOOLS_LOG_LEVEL` environment variable
636+
637+
If you set `Logger` level lower than ALC, we will emit a warning informing you that your messages will be discarded by Lambda.
638+
639+
> **NOTE**
640+
>
641+
> 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){target="_blank"} for more details.
642+
643+
### Timestamp format
644+
645+
When the Advanced Logging Controls feature is enabled, Powertools for AWS Lambda must comply with the timestamp format required by AWS Lambda, which is [RFC3339](https://www.rfc-editor.org/rfc/rfc3339).
646+
In this case the format will be `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`.
601647

602648
## Upgrade to JsonTemplateLayout from deprecated LambdaJsonLayout configuration in log4j2.xml
603649

docs/index.md

+38-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Powertools for AWS Lambda (Java) is a suite of utilities for AWS Lambda Function
1111
Powertools for AWS Lambda is also available for [Python](https://docs.powertools.aws.dev/lambda/python/latest/){target="_blank"}, [TypeScript](https://docs.powertools.aws.dev/lambda/typescript/latest/){target="_blank"}, and [.NET](https://docs.powertools.aws.dev/lambda/dotnet/){target="_blank"}
1212

1313

14-
!!! tip "Looking for a quick run through of the core utilities?"
14+
???+ tip "Looking for a quick run through of the core utilities?"
1515
Check out [this detailed blog post](https://aws.amazon.com/blogs/opensource/simplifying-serverless-best-practices-with-aws-lambda-powertools-java/) with a practical example. To dive deeper,
1616
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.
1717

@@ -274,6 +274,41 @@ Depending on your version of Java (either Java 1.8 or 11+), the configuration sl
274274
Under the hood, `org.codehaus.mojo:aspectj-maven-plugin` is based on AspectJ 1.9.7,
275275
while `dev.aspectj:aspectj-maven-plugin` is based on AspectJ 1.9.8, compiled for Java 11+.
276276

277+
### Java Compatibility
278+
Powertools for AWS Lambda (Java) supports all Java version from 8 up to 21 as well as the
279+
[corresponding Lambda runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html).
280+
281+
For the following modules, Powertools for AWS Lambda (Java) leverages the **aspectj** library to provide annotations:
282+
- Logging
283+
- Metrics
284+
- Tracing
285+
- Parameters
286+
- Idempotency
287+
- Validation
288+
- Large messages
289+
290+
291+
You may need to add the good version of `aspectjrt` to your dependencies based on the jdk used for building your function:
292+
293+
```xml
294+
<dependency>
295+
<groupId>org.aspectj</groupId>
296+
<artifactId>aspectjrt</artifactId>
297+
<version>1.9.??</version>
298+
</dependency>
299+
```
300+
301+
Use the following [dependency matrix](https://github.com/eclipse-aspectj/aspectj/blob/master/docs/dist/doc/JavaVersionCompatibility.md) between this library and the JDK:
302+
303+
| JDK version | aspectj version |
304+
|-------------|-----------------|
305+
| `1.8` | `1.9.7` |
306+
| `11-17` | `1.9.20.1` |
307+
| `21` | `1.9.21` |
308+
309+
_Note: 1.9.21 is not yet available and Java 21 not yet officially supported by aspectj, but you can already use the `1.9.21.M1`_
310+
311+
277312
## Environment variables
278313

279314
!!! info
@@ -285,5 +320,7 @@ Depending on your version of Java (either Java 1.8 or 11+), the configuration sl
285320
| **POWERTOOLS_METRICS_NAMESPACE** | Sets namespace used for metrics | [Metrics](./core/metrics) |
286321
| **POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logging) |
287322
| **POWERTOOLS_LOG_LEVEL** | Sets logging level | [Logging](./core/logging) |
323+
| **POWERTOOLS_LOGGER_LOG_EVENT** | Enables/Disables whether to log the incoming event when using the aspect | [Logging](./core/logging) |
288324
| **POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Enables/Disables tracing mode to capture method response | [Tracing](./core/tracing) |
289325
| **POWERTOOLS_TRACER_CAPTURE_ERROR** | Enables/Disables tracing mode to capture method error | [Tracing](./core/tracing) |
326+

examples/powertools-examples-core-utilities/cdk/infra/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<version>2.0.0-SNAPSHOT</version>
88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10-
<cdk.version>2.93.0</cdk.version>
10+
<cdk.version>2.100.0</cdk.version>
1111
<constructs.version>[10.0.0,11.0.0)</constructs.version>
1212
<junit.version>5.10.0</junit.version>
1313
</properties>

examples/powertools-examples-core-utilities/gradle/build.gradle

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ compileJava {
1818
}
1919

2020
repositories {
21+
mavenLocal()
2122
mavenCentral()
2223
}
2324

@@ -27,8 +28,8 @@ dependencies {
2728
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2.2'
2829
implementation 'com.amazonaws:aws-lambda-java-events:3.11.0'
2930
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2'
30-
aspect 'software.amazon.lambda:powertools-tracing:1.17.0'
31-
aspect 'software.amazon.lambda:powertools-logging:1.17.0'
32-
aspect 'software.amazon.lambda:powertools-metrics:1.17.0'
31+
aspect 'software.amazon.lambda:powertools-tracing:2.0.0-SNAPSHOT'
32+
aspect 'software.amazon.lambda:powertools-logging:2.0.0-SNAPSHOT'
33+
aspect 'software.amazon.lambda:powertools-metrics:2.0.0-SNAPSHOT'
3334
}
3435

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extra_javascript:
8585

8686
extra:
8787
powertools:
88-
version: 1.17.0 # to update after each release (we do not want snapshot version here)
88+
version: 1.18.0 # to update after each release (we do not want snapshot version here)
8989

9090
repo_url: https://github.com/aws-powertools/powertools-lambda-java
9191
edit_uri: edit/main/docs

pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
<maven.compiler.target>1.8</maven.compiler.target>
7474
<log4j.version>2.20.0</log4j.version>
7575
<jackson.version>2.15.3</jackson.version>
76-
<aspectj.version>1.9.7</aspectj.version>
7776
<aws.sdk.version>2.21.0</aws.sdk.version>
7877
<aws.xray.recorder.version>2.14.0</aws.xray.recorder.version>
7978
<payloadoffloading-common.version>2.1.3</payloadoffloading-common.version>
@@ -82,6 +81,7 @@
8281
<lambda.events.version>3.11.2</lambda.events.version>
8382
<lambda.serial.version>1.1.2</lambda.serial.version>
8483
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
84+
<aspectj.version>1.9.7</aspectj.version>
8585
<aspectj-maven-plugin.version>1.13.1</aspectj-maven-plugin.version>
8686
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
8787
<jacoco-maven-plugin.version>0.8.10</jacoco-maven-plugin.version>
@@ -514,6 +514,7 @@
514514
</plugins>
515515
</build>
516516
</profile>
517+
517518
<profile>
518519
<id>jdk16</id>
519520
<activation>

powertools-cloudformation/pom.xml

+4-8
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
<groupId>com.fasterxml.jackson.core</groupId>
7777
<artifactId>jackson-databind</artifactId>
7878
</dependency>
79+
<dependency>
80+
<groupId>org.aspectj</groupId>
81+
<artifactId>aspectjrt</artifactId>
82+
</dependency>
7983

8084
<!-- Test dependencies -->
8185
<dependency>
@@ -107,14 +111,6 @@
107111

108112
<build>
109113
<plugins>
110-
<plugin>
111-
<groupId>dev.aspectj</groupId>
112-
<artifactId>aspectj-maven-plugin</artifactId>
113-
<version>${aspectj-maven-plugin.version}</version>
114-
<configuration>
115-
<skip>true</skip>
116-
</configuration>
117-
</plugin>
118114
<plugin>
119115
<groupId>org.apache.maven.plugins</groupId>
120116
<artifactId>maven-checkstyle-plugin</artifactId>

powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/LambdaConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class LambdaConstants {
2424
@Deprecated
2525
public static final String ON_DEMAND = "on-demand";
2626
public static final String X_AMZN_TRACE_ID = "_X_AMZN_TRACE_ID";
27+
public static final String XRAY_TRACE_HEADER = "com.amazonaws.xray.traceHeader";
2728
public static final String AWS_SAM_LOCAL = "AWS_SAM_LOCAL";
2829
public static final String ROOT_EQUALS = "Root=";
2930
public static final String POWERTOOLS_SERVICE_NAME = "POWERTOOLS_SERVICE_NAME";

0 commit comments

Comments
 (0)