Skip to content

Commit d3b5a72

Browse files
committed
Merge, accepting both sides for deleted files
2 parents 8586bf6 + 897f7e9 commit d3b5a72

File tree

72 files changed

+3157
-1042
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3157
-1042
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Artifacts Size
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- 'powertools-cloudformation/**'
9+
- 'powertools-core/**'
10+
- 'powertools-serialization/**'
11+
- 'powertools-logging/**'
12+
- 'powertools-sqs/**'
13+
- 'powertools-tracing/**'
14+
- 'powertools-validation/**'
15+
- 'powertools-parameters/**'
16+
- 'powertools-idempotency/**'
17+
- 'powertools-metrics/**'
18+
- 'pom.xml'
19+
jobs:
20+
codecheck:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
24+
- name: Setup java JDK 11
25+
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
26+
with:
27+
distribution: 'corretto'
28+
java-version: 11
29+
- name: Build with Maven
30+
run: mvn clean package --file pom.xml -DskipTests
31+
- name: Get artifacts size & build report
32+
id: artifacts-size-report
33+
run: |
34+
echo '## :floppy_disk: Artifacts Size Report' > report.md
35+
echo '| Module | Version | Size (KB) |' >> report.md
36+
echo '| --- | --- | --- |' >> report.md
37+
artifact_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
38+
for artifact in $(cat target/powertools-parent-*.buildinfo | grep 'outputs.*.jar' | grep -v 'sources.jar'); do
39+
artifact_name=$(echo "$artifact" | cut -d '=' -f2)
40+
artifact_name=${artifact_name%-$artifact_version.jar}
41+
artifact_size=$(grep "${artifact%%.filename*}.length" target/powertools-parent-*.buildinfo | cut -d '=' -f2)
42+
printf "| %s | %s | %.2f |\n" "$artifact_name" "$artifact_version" "$(bc <<< "scale=2; $artifact_size/1000")" >> report.md
43+
done
44+
- name: Find potential existing report
45+
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # 2.4.0
46+
id: find-comment
47+
with:
48+
issue-number: ${{ github.event.pull_request.number }}
49+
comment-author: 'github-actions[bot]'
50+
body-includes: Artifacts Size Report
51+
- name: Write artifacts size report in comment
52+
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # 3.0.2
53+
with:
54+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
55+
issue-number: ${{ github.event.pull_request.number }}
56+
body-path: 'report.md'
57+
edit-mode: replace
File renamed without changes.

docs/core/logging.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ You can set a Correlation ID using `correlationIdPath` attribute by passing a [J
347347
"functionName": "test",
348348
"functionMemorySize": 128,
349349
"functionArn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
350-
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
350+
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
351351
"correlation_id": "correlation_id_value"
352352
}
353353
```
@@ -397,7 +397,7 @@ for known event sources, where either a request ID or X-Ray Trace ID are present
397397
"functionName": "test",
398398
"functionMemorySize": 128,
399399
"functionArn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
400-
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
400+
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
401401
"correlation_id": "correlation_id_value"
402402
}
403403
```
@@ -510,7 +510,7 @@ this means that custom keys can be persisted across invocations. If you want all
510510
"functionName": "test",
511511
"functionMemorySize": 128,
512512
"functionArn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
513-
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
513+
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72",
514514
"specialKey": "value"
515515
}
516516
```
@@ -527,7 +527,7 @@ this means that custom keys can be persisted across invocations. If you want all
527527
"functionName": "test",
528528
"functionMemorySize": 128,
529529
"functionArn": "arn:aws:lambda:eu-west-1:12345678910:function:test",
530-
"lambda_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72"
530+
"function_request_id": "52fdfc07-2182-154f-163f-5f0f9a621d72"
531531
}
532532
```
533533

docs/stylesheets/extra.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
}
44

55
.highlight .hll {
6-
background-color: lavender
6+
[data-md-color-scheme="default"] {
7+
background-color: lavender;
8+
}
79
}
810

911
.md-typeset table:not([class]) {

examples/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ Each example can be copied from its subdirectory and used independently of the r
55

66
## Examples
77

8-
* [powertools-examples-core-utilities](powertools-examples-core-utilities) - Demonstrates the core logging, tracing, and metrics modules with different build tools
9-
* [SAM](powertools-examples-core-utilities/sam)
10-
* [CDK](powertools-examples-core-utilities/cdk)
8+
* [powertools-examples-core](powertools-examples-core) - Demonstrates the core logging, tracing, and metrics modules with different build tools
9+
* [SAM](./powertools-examples-core/sam)
10+
* [CDK](./powertools-examples-core/cdk)
11+
* [Serverless](./powertools-examples-core/serverless)
1112
* [powertools-examples-idempotency](powertools-examples-idempotency) - An idempotent HTTP API
1213
* [powertools-examples-parameters](powertools-examples-parameters) - Uses the parameters module to provide runtime parameters to a function
1314
* [powertools-examples-serialization](powertools-examples-serialization) - Uses the serialization module to serialize and deserialize API Gateway & SQS payloads
@@ -54,7 +55,7 @@ The first command will build the source of your application. The second command
5455

5556
You can find your API Gateway Endpoint URL in the output values displayed after deployment.
5657

57-
If you're not using SAM, you can look for examples for other tools under [powertools-examples-core-utilities](./powertools-examples-core-utilities)
58+
If you're not using SAM, you can look for examples for other tools under [powertools-examples-core](./powertools-examples-core)
5859

5960
### External examples
6061

examples/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
</description>
3030

3131
<modules>
32-
<module>powertools-examples-core-utilities/sam</module>
33-
<module>powertools-examples-core-utilities/cdk/app</module>
34-
<module>powertools-examples-core-utilities/cdk/infra</module>
32+
<module>powertools-examples-core/sam</module>
33+
<module>powertools-examples-core/cdk/app</module>
34+
<module>powertools-examples-core/cdk/infra</module>
35+
<module>powertools-examples-core/serverless</module>
3536
<module>powertools-examples-idempotency</module>
3637
<module>powertools-examples-parameters</module>
3738
<module>powertools-examples-serialization</module>

examples/powertools-examples-batch/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
<log4j.version>2.20.0</log4j.version>
1515
<maven.compiler.source>1.8</maven.compiler.source>
1616
<maven.compiler.target>1.8</maven.compiler.target>
17-
<sdk.version>2.20.133</sdk.version>
18-
<aspectj.version>1.9.20</aspectj.version>
17+
<sdk.version>2.20.152</sdk.version>
1918
</properties>
2019

2120
<dependencies>

examples/powertools-examples-cloudformation/pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44

55
<groupId>software.amazon.lambda.examples</groupId>
6-
<version>2.0.0-SNAPSHOT</version>
6+
<version>1.17.0-SNAPSHOT</version>
77
<artifactId>powertools-examples-cloudformation</artifactId>
88
<packaging>jar</packaging>
99

@@ -14,9 +14,8 @@
1414
<maven.compiler.source>1.8</maven.compiler.source>
1515
<maven.compiler.target>1.8</maven.compiler.target>
1616
<lambda.core.version>1.2.3</lambda.core.version>
17-
<lambda.events.version>3.11.2</lambda.events.version>
18-
<aws.sdk.version>2.20.136</aws.sdk.version>
19-
<aspectj.version>1.9.20</aspectj.version>
17+
<lambda.events.version>3.11.3</lambda.events.version>
18+
<aws.sdk.version>2.20.162</aws.sdk.version>
2019
</properties>
2120
<dependencyManagement>
2221
<dependencies>

examples/powertools-examples-core-utilities/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ We provide examples for the following infrastructure-as-code tools:
99

1010
* [AWS SAM](sam/)
1111
* [AWS CDK](cdk/)
12+
* [Serverless framework](serverless/)
1213

1314
We also provide an example showing the integration of SAM, Powertools, and Gradle:
1415

15-
* [AWS SAM with a Gradle build](../powertools-examples-core-utilities/gradle/)
16+
* [AWS SAM with a Gradle build](gradle/)
1617

1718
For each of the tools, the example application is the same, and consists of the following files:
1819

examples/powertools-examples-core-utilities/cdk/app/src/main/java/helloworld/App.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@
4646
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
4747
private final static Logger log = LogManager.getLogger(App.class);
4848

49-
@Logging(logEvent = true, samplingRate = 0.7)
49+
// This is controlled by POWERTOOLS_LOGGER_SAMPLE_RATE environment variable
50+
// @Logging(logEvent = true, samplingRate = 0.7)
51+
// This is controlled by POWERTOOLS_METRICS_NAMESPACE environment variable
52+
// @Metrics(namespace = "ServerlessAirline", service = "payment", captureColdStart = true)
53+
// This is controlled by POWERTOOLS_TRACER_CAPTURE_ERROR environment variable
5054
@Tracing(captureMode = CaptureMode.RESPONSE_AND_ERROR)
51-
@Metrics(namespace = "ServerlessAirline", service = "payment", captureColdStart = true)
5255
public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
5356
Map<String, String> headers = new HashMap<>();
5457

@@ -84,18 +87,25 @@ public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEv
8487
return response
8588
.withStatusCode(200)
8689
.withBody(output);
90+
<<<<<<<< HEAD:examples/powertools-examples-core-utilities/cdk/app/src/main/java/helloworld/App.java
8791
} catch (IOException e) {
92+
========
93+
} catch (RuntimeException | IOException e) {
94+
>>>>>>>> main:examples/powertools-examples-core/serverless/src/main/java/helloworld/App.java
8895
return response
8996
.withBody("{}")
9097
.withStatusCode(500);
9198
}
9299
}
93100

101+
<<<<<<<< HEAD:examples/powertools-examples-core-utilities/cdk/app/src/main/java/helloworld/App.java
94102
@Tracing
95103
private void log() {
96104
log.info("inside threaded logging for function");
97105
}
98106

107+
========
108+
>>>>>>>> main:examples/powertools-examples-core/serverless/src/main/java/helloworld/App.java
99109
@Tracing(namespace = "getPageContents", captureMode = CaptureMode.DISABLED)
100110
private String getPageContents(String address) throws IOException {
101111
URL url = new URL(address);

examples/powertools-examples-core-utilities/sam/pom.xml

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

55
<groupId>software.amazon.lambda.examples</groupId>
6+
<<<<<<<< HEAD:examples/powertools-examples-core-utilities/sam/pom.xml
67
<version>2.0.0-SNAPSHOT</version>
78
<artifactId>powertools-examples-core-utilities-sam</artifactId>
89
<packaging>jar</packaging>
910

1011
<name>Powertools for AWS Lambda (Java) library Examples - Core Utilities (logging, tracing, metrics) with SAM</name>
12+
========
13+
<version>1.16.1</version>
14+
<artifactId>powertools-examples-core-cdk</artifactId>
15+
<packaging>jar</packaging>
16+
17+
<name>Powertools for AWS Lambda (Java) library Examples - Core</name>
18+
>>>>>>>> main:examples/powertools-examples-core/cdk/app/pom.xml
1119

1220
<properties>
1321
<log4j.version>2.20.0</log4j.version>
1422
<maven.compiler.source>1.8</maven.compiler.source>
1523
<maven.compiler.target>1.8</maven.compiler.target>
24+
<<<<<<<< HEAD:examples/powertools-examples-core-utilities/sam/pom.xml
1625
<aspectj.version>1.9.20</aspectj.version>
26+
========
27+
>>>>>>>> main:examples/powertools-examples-core/cdk/app/pom.xml
1728
</properties>
1829

1930
<dependencies>
@@ -40,7 +51,11 @@
4051
<dependency>
4152
<groupId>com.amazonaws</groupId>
4253
<artifactId>aws-lambda-java-events</artifactId>
54+
<<<<<<<< HEAD:examples/powertools-examples-core-utilities/sam/pom.xml
4355
<version>3.11.2</version>
56+
========
57+
<version>3.11.3</version>
58+
>>>>>>>> main:examples/powertools-examples-core/cdk/app/pom.xml
4459
</dependency>
4560
<dependency>
4661
<groupId>org.apache.logging.log4j</groupId>
@@ -67,6 +82,7 @@
6782
</dependencies>
6883

6984
<build>
85+
<<<<<<<< HEAD:examples/powertools-examples-core-utilities/sam/pom.xml
7086
<plugins>
7187
<plugin>
7288
<groupId>dev.aspectj</groupId>
@@ -132,6 +148,75 @@
132148
</dependencies>
133149
</plugin>
134150
</plugins>
151+
========
152+
<finalName>helloworld-lambda</finalName>
153+
<plugins>
154+
<plugin>
155+
<groupId>dev.aspectj</groupId>
156+
<artifactId>aspectj-maven-plugin</artifactId>
157+
<version>1.13.1</version>
158+
<configuration>
159+
<source>${maven.compiler.source}</source>
160+
<target>${maven.compiler.target}</target>
161+
<complianceLevel>${maven.compiler.target}</complianceLevel>
162+
<aspectLibraries>
163+
<aspectLibrary>
164+
<groupId>software.amazon.lambda</groupId>
165+
<artifactId>powertools-tracing</artifactId>
166+
</aspectLibrary>
167+
<aspectLibrary>
168+
<groupId>software.amazon.lambda</groupId>
169+
<artifactId>powertools-logging</artifactId>
170+
</aspectLibrary>
171+
<aspectLibrary>
172+
<groupId>software.amazon.lambda</groupId>
173+
<artifactId>powertools-metrics</artifactId>
174+
</aspectLibrary>
175+
</aspectLibraries>
176+
</configuration>
177+
<executions>
178+
<execution>
179+
<goals>
180+
<goal>compile</goal>
181+
</goals>
182+
</execution>
183+
</executions>
184+
</plugin>
185+
<plugin>
186+
<groupId>org.apache.maven.plugins</groupId>
187+
<artifactId>maven-shade-plugin</artifactId>
188+
<version>3.5.0</version>
189+
<executions>
190+
<execution>
191+
<phase>package</phase>
192+
<goals>
193+
<goal>shade</goal>
194+
</goals>
195+
<configuration>
196+
<transformers>
197+
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
198+
</transformers>
199+
</configuration>
200+
</execution>
201+
</executions>
202+
<dependencies>
203+
<dependency>
204+
<groupId>org.apache.logging.log4j</groupId>
205+
<artifactId>log4j-transform-maven-shade-plugin-extensions</artifactId>
206+
<version>0.1.0</version>
207+
</dependency>
208+
</dependencies>
209+
</plugin>
210+
<!-- Don't deploy the example -->
211+
<plugin>
212+
<groupId>org.apache.maven.plugins</groupId>
213+
<artifactId>maven-deploy-plugin</artifactId>
214+
<configuration>
215+
<skip>true</skip>
216+
</configuration>
217+
</plugin>
218+
</plugins>
219+
>>>>>>>> main:examples/powertools-examples-core/cdk/app/pom.xml
135220
</build>
136221
<profiles>
137222
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Powertools for AWS Lambda (Java) - Core Utilities Example with CDK
2+
3+
This project demonstrates the Lambda for Powertools Java module deployed using [Cloud Development Kit](https://aws.amazon.com/cdk/).
4+
5+
For general information on the deployed example itself, you can refer to the parent [README](../README.md)
6+
7+
## Configuration
8+
CDK uses the following project structure:
9+
- [app](./app) - stores the source code of your application, which is similar between all examples
10+
- [infra](./infra) - stores the definition of your infrastructure
11+
- [cdk.json](./infra/cdk.json) - tells the CDK Toolkit how to execute your app
12+
- [CdkApp](./infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input
13+
- [CdkStack](./infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it.
14+
15+
It is a [Maven](https://maven.apache.org/) based project, so you can open this project with any Maven compatible Java IDE to build and run tests.
16+
17+
18+
## Deploy the sample application
19+
20+
The minimum to deploy the app should be
21+
```bash
22+
cdk deploy
23+
```
24+
25+
If you're running CDK for the first time, you'll need to first run the bootstrap command:
26+
```bash
27+
cdk bootstrap
28+
```
29+
30+
## Useful commands
31+
32+
* `mvn package` compile and run tests
33+
* `cdk synth` emits the synthesized CloudFormation template
34+
* `cdk deploy` deploy this stack to your default AWS account/region
35+
* `cdk diff` compare deployed stack with current state
36+
* `cdk docs` open CDK documentation

0 commit comments

Comments
 (0)