Skip to content

Commit 46e76f9

Browse files
committed
Merge branch 'v2' into chore/remove-deprecated
2 parents 68225bd + 1317da4 commit 46e76f9

File tree

33 files changed

+321
-149
lines changed

33 files changed

+321
-149
lines changed
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Docs
2+
on:
3+
push:
4+
branches:
5+
- v2
6+
workflow_dispatch: {}
7+
8+
permissions:
9+
id-token: write
10+
contents: write
11+
pages: write
12+
13+
jobs:
14+
docs:
15+
runs-on: ubuntu-latest
16+
environment: Docs
17+
steps:
18+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
19+
- name: Set up Python
20+
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1
21+
with:
22+
python-version: "3.8"
23+
- name: Capture branch and tag
24+
id: branch_name
25+
run: |
26+
echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
27+
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
28+
- name: Build docs website
29+
run: |
30+
make build-docs-website
31+
- name: Configure AWS credentials
32+
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef
33+
with:
34+
aws-region: us-east-1
35+
role-to-assume: ${{ secrets.AWS_DOCS_ROLE_ARN }}
36+
- name: Deploy Docs
37+
run: |
38+
aws s3 sync \
39+
dist \
40+
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/preview/
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish v2
2+
on:
3+
push:
4+
branches:
5+
- v2
6+
workflow_dispatch: {}
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
environment: snapshot
11+
steps:
12+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
13+
- name: Set up Maven Central Repository
14+
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 # v3.11.0
15+
with:
16+
distribution: 'corretto'
17+
java-version: 11
18+
server-id: ossrh
19+
server-username: MAVEN_USERNAME
20+
server-password: MAVEN_PASSWORD
21+
# TODO: use environments https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
22+
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }} # Value of the GPG private key to import
23+
gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase
24+
- name: Publish package
25+
run: mvn -Prelease clean validate deploy -DskipTests # We use validate here to run maven enforcer, to make sure we are only publishing SNAPSHOT builds
26+
env:
27+
MAVEN_USERNAME: ${{ secrets.SNAPSHOT_PUBLISH_USERNAME }}
28+
MAVEN_PASSWORD: ${{ secrets.SNAPSHOT_PUBLISH_PASSWORD }}
29+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

.github/workflows/publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
- name: Publish package
2828
run: mvn -Prelease clean deploy -DskipTests
2929
env:
30-
MAVEN_USERNAME: ${{ secrets.OSSRH_JIRA_USERNAME }}
31-
MAVEN_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }}
30+
MAVEN_USERNAME: ${{ secrets.SNAPSHOT_PUBLISH_USERNAME }}
31+
MAVEN_PASSWORD: ${{ secrets.SNAPSHOT_PUBLISH_PASSWORD }}
3232
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
3333
- name: Close issues related to this release
3434
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ on:
2424
pull_request:
2525
branches:
2626
- main
27-
- v2
2827
paths:
2928
- 'powertools-e2e-tests/**'
3029

@@ -63,4 +62,4 @@ jobs:
6362
if: ${{ matrix.java != '8' }} # If not 8 don't exclude the examples directory
6463
run: mvn -DskipTests install --file pom.xml
6564
- name: Run e2e test with Maven
66-
run: mvn -Pe2e -B verify --file powertools-e2e-tests/pom.xml
65+
run: mvn -Pe2e -B verify --file powertools-e2e-tests/pom.xml

docs/core/metrics.md

+37-75
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ If you're new to Amazon CloudWatch, there are two terminologies you must be awar
2828

2929
## Install
3030

31-
Depending on your version of Java (either Java 1.8 or 11+), the configuration slightly changes.
32-
33-
=== "Maven Java 11+"
31+
=== "Maven"
3432

3533
```xml hl_lines="3-7 16 18 24-27"
3634
<dependencies>
@@ -75,52 +73,7 @@ If you're new to Amazon CloudWatch, there are two terminologies you must be awar
7573
</build>
7674
```
7775

78-
=== "Maven Java 1.8"
79-
80-
```xml hl_lines="3-7 16 18 24-27"
81-
<dependencies>
82-
...
83-
<dependency>
84-
<groupId>software.amazon.lambda</groupId>
85-
<artifactId>powertools-metrics</artifactId>
86-
<version>{{ powertools.version }}</version>
87-
</dependency>
88-
...
89-
</dependencies>
90-
...
91-
<!-- configure the aspectj-maven-plugin to compile-time weave (CTW) the aws-lambda-powertools-java aspects into your project -->
92-
<build>
93-
<plugins>
94-
...
95-
<plugin>
96-
<groupId>org.codehaus.mojo</groupId>
97-
<artifactId>aspectj-maven-plugin</artifactId>
98-
<version>1.14.0</version>
99-
<configuration>
100-
<source>1.8</source>
101-
<target>1.8</target>
102-
<complianceLevel>1.8</complianceLevel>
103-
<aspectLibraries>
104-
<aspectLibrary>
105-
<groupId>software.amazon.lambda</groupId>
106-
<artifactId>powertools-metrics</artifactId>
107-
</aspectLibrary>
108-
</aspectLibraries>
109-
</configuration>
110-
<executions>
111-
<execution>
112-
<goals>
113-
<goal>compile</goal>
114-
</goals>
115-
</execution>
116-
</executions>
117-
</plugin>
118-
...
119-
</plugins>
120-
</build>
121-
```
122-
123-
=== "Gradle Java 11+"
76+
=== "Gradle"
12477

12578
```groovy hl_lines="3 11"
12679
plugins {
@@ -140,34 +93,14 @@ If you're new to Amazon CloudWatch, there are two terminologies you must be awar
14093
targetCompatibility = 11
14194
```
14295

143-
=== "Gradle Java 1.8"
144-
145-
```groovy hl_lines="3 11"
146-
plugins {
147-
id 'java'
148-
id 'io.freefair.aspectj.post-compile-weaving' version '6.6.3'
149-
}
150-
151-
repositories {
152-
mavenCentral()
153-
}
154-
155-
dependencies {
156-
aspect 'software.amazon.lambda:powertools-metrics:{{ powertools.version }}'
157-
}
158-
159-
sourceCompatibility = 1.8
160-
targetCompatibility = 1.8
161-
```
162-
16396
## Getting started
16497

16598
Metric has two global settings that will be used across all metrics emitted:
16699

167-
Setting | Description | Environment variable | Constructor parameter
168-
------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- | -------------------------------------------------
169-
**Metric namespace** | Logical container where all metrics will be placed e.g. `ServerlessAirline` | `POWERTOOLS_METRICS_NAMESPACE` | `namespace`
170-
**Service** | Optionally, sets **service** metric dimension across all metrics e.g. `payment` | `POWERTOOLS_SERVICE_NAME` | `service`
100+
| Setting | Description | Environment variable | Constructor parameter |
101+
|----------------------|---------------------------------------------------------------------------------|--------------------------------|-----------------------|
102+
| **Metric namespace** | Logical container where all metrics will be placed e.g. `ServerlessAirline` | `POWERTOOLS_METRICS_NAMESPACE` | `namespace` |
103+
| **Service** | Optionally, sets **service** metric dimension across all metrics e.g. `payment` | `POWERTOOLS_SERVICE_NAME` | `service` |
171104

172105
!!! tip "Use your application or main service as the metric namespace to easily group all metrics"
173106

@@ -198,7 +131,7 @@ Setting | Description | Environment variable | Constructor parameter
198131
@Override
199132
@Metrics(namespace = "ExampleApplication", service = "booking")
200133
public Object handleRequest(Object input, Context context) {
201-
...
134+
// ...
202135
}
203136
}
204137
```
@@ -224,7 +157,7 @@ You can create metrics using `putMetric`, and manually create dimensions for all
224157
public Object handleRequest(Object input, Context context) {
225158
metricsLogger.putDimensions(DimensionSet.of("environment", "prod"));
226159
metricsLogger.putMetric("SuccessfulBooking", 1, Unit.COUNT);
227-
...
160+
// ...
228161
}
229162
}
230163
```
@@ -234,6 +167,35 @@ You can create metrics using `putMetric`, and manually create dimensions for all
234167
!!! note "Metrics overflow"
235168
CloudWatch EMF supports a max of 100 metrics. Metrics utility will flush all metrics when adding the 100th metric while subsequent metrics will be aggregated into a new EMF object, for your convenience.
236169

170+
171+
### Adding high-resolution metrics
172+
173+
You can create [high-resolution metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html#high-resolution-metrics)
174+
passing a `storageResolution` to the `putMetric` method:
175+
176+
=== "HigResMetricsHandler.java"
177+
178+
```java hl_lines="3 13"
179+
import software.amazon.lambda.powertools.metrics.Metrics;
180+
import software.amazon.cloudwatchlogs.emf.logger.MetricsLogger;
181+
import software.amazon.cloudwatchlogs.emf.model.StorageResolution;
182+
183+
public class MetricsEnabledHandler implements RequestHandler<Object, Object> {
184+
185+
MetricsLogger metricsLogger = MetricsUtils.metricsLogger();
186+
187+
@Override
188+
@Metrics(namespace = "ExampleApplication", service = "booking")
189+
public Object handleRequest(Object input, Context context) {
190+
// ...
191+
metricsLogger.putMetric("SuccessfulBooking", 1, Unit.COUNT, StorageResolution.HIGH);
192+
}
193+
}
194+
```
195+
196+
!!! info "When is it useful?"
197+
High-resolution metrics are data with a granularity of one second and are very useful in several situations such as telemetry, time series, real-time incident management, and others.
198+
237199
### Flushing metrics
238200

239201
The `@Metrics` annotation **validates**, **serializes**, and **flushes** all your metrics. During metrics validation,

docs/index.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ title: Homepage
33
description: Powertools for AWS Lambda (Java)
44
---
55

6-
![aws provider](https://img.shields.io/badge/provider-AWS-orange?logo=amazon-aws&color=ff9900) ![Build status](https://github.com/aws-powertools/powertools-lambda-java/actions/workflows/build.yml/badge.svg) ![Maven Central](https://img.shields.io/maven-central/v/software.amazon.lambda/powertools-parent)
6+
![aws provider](https://img.shields.io/badge/provider-AWS-orange?logo=amazon-aws&color=ff9900) ![Build status](https://github.com/aws-powertools/powertools-lambda-java/actions/workflows/publish-v2-snapshot.yml/badge.svg) ![Maven Central](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Faws.oss.sonatype.org%2Fcontent%2Frepositories%2Fsnapshots%2Fsoftware%2Famazon%2Flambda%2Fpowertools-parent%2Fmaven-metadata.xml
7+
)
8+
9+
???+ warning
10+
You are browsing the documentation for Powertools for AWS Lambda (Java) - v2. This is a snapshot release and not stable!
11+
Check out our stable [v1](https://docs.powertools.aws.dev/lambda/java/) documentation if this is not what you wanted.
12+
The v2 maven snapshot repository can be found [here](https://aws.oss.sonatype.org/content/repositories/snapshots/software/amazon/lambda/) .
713

814
Powertools for AWS Lambda (Java) is a suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier.
915

examples/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<plugin>
4949
<groupId>org.apache.maven.plugins</groupId>
5050
<artifactId>maven-deploy-plugin</artifactId>
51-
<version>3.1.1</version>
51+
<version>3.1.2</version>
5252
<configuration>
5353
<skip>true</skip>
5454
</configuration>

examples/powertools-examples-batch/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<maven.compiler.source>11</maven.compiler.source>
1515
<maven.compiler.target>11</maven.compiler.target>
1616
<aspectj.version>1.9.20.1</aspectj.version>
17-
<sdk.version>2.25.26</sdk.version>
17+
<sdk.version>2.26.7</sdk.version>
1818
</properties>
1919

2020
<dependencies>
@@ -75,7 +75,7 @@
7575
<plugin>
7676
<groupId>dev.aspectj</groupId>
7777
<artifactId>aspectj-maven-plugin</artifactId>
78-
<version>1.13.1</version>
78+
<version>1.14</version>
7979
<configuration>
8080
<source>${maven.compiler.source}</source>
8181
<target>${maven.compiler.target}</target>
@@ -109,7 +109,7 @@
109109
<plugin>
110110
<groupId>org.apache.maven.plugins</groupId>
111111
<artifactId>maven-shade-plugin</artifactId>
112-
<version>3.5.2</version>
112+
<version>3.6.0</version>
113113
<executions>
114114
<execution>
115115
<phase>package</phase>
@@ -136,7 +136,7 @@
136136
<plugin>
137137
<groupId>org.apache.maven.plugins</groupId>
138138
<artifactId>maven-deploy-plugin</artifactId>
139-
<version>3.1.1</version>
139+
<version>3.1.2</version>
140140
<configuration>
141141
<skip>true</skip>
142142
</configuration>

examples/powertools-examples-cloudformation/pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<maven.compiler.target>11</maven.compiler.target>
1515
<lambda.core.version>1.2.3</lambda.core.version>
1616
<lambda.events.version>3.11.3</lambda.events.version>
17-
<aws.sdk.version>2.25.21</aws.sdk.version>
17+
<aws.sdk.version>2.25.35</aws.sdk.version>
1818
<aspectj.version>1.9.20.1</aspectj.version>
1919

2020
</properties>
@@ -87,7 +87,7 @@
8787
<plugin>
8888
<groupId>dev.aspectj</groupId>
8989
<artifactId>aspectj-maven-plugin</artifactId>
90-
<version>1.13.1</version>
90+
<version>1.14</version>
9191
<configuration>
9292
<source>${maven.compiler.source}</source>
9393
<target>${maven.compiler.target}</target>
@@ -117,7 +117,7 @@
117117
<plugin>
118118
<groupId>org.apache.maven.plugins</groupId>
119119
<artifactId>maven-shade-plugin</artifactId>
120-
<version>3.5.0</version>
120+
<version>3.6.0</version>
121121
<executions>
122122
<execution>
123123
<phase>package</phase>
@@ -144,7 +144,7 @@
144144
<plugin>
145145
<groupId>org.apache.maven.plugins</groupId>
146146
<artifactId>maven-deploy-plugin</artifactId>
147-
<version>3.1.1</version>
147+
<version>3.1.2</version>
148148
<configuration>
149149
<skip>true</skip>
150150
</configuration>

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<packaging>jar</packaging>
1212

1313
<properties>
14-
<log4j.version>2.20.0</log4j.version>
14+
<log4j.version>2.23.1</log4j.version>
1515
<maven.compiler.source>11</maven.compiler.source>
1616
<maven.compiler.target>11</maven.compiler.target>
1717
<aspectj.version>1.9.20.1</aspectj.version>
@@ -66,7 +66,7 @@
6666
<plugin>
6767
<groupId>dev.aspectj</groupId>
6868
<artifactId>aspectj-maven-plugin</artifactId>
69-
<version>1.13.1</version>
69+
<version>1.14</version>
7070
<configuration>
7171
<source>${maven.compiler.source}</source>
7272
<target>${maven.compiler.target}</target>
@@ -104,7 +104,7 @@
104104
<plugin>
105105
<groupId>org.apache.maven.plugins</groupId>
106106
<artifactId>maven-shade-plugin</artifactId>
107-
<version>3.5.0</version>
107+
<version>3.6.0</version>
108108
<executions>
109109
<execution>
110110
<phase>package</phase>
@@ -132,7 +132,7 @@
132132
<plugin>
133133
<groupId>org.apache.maven.plugins</groupId>
134134
<artifactId>maven-deploy-plugin</artifactId>
135-
<version>3.1.1</version>
135+
<version>3.1.2</version>
136136
<configuration>
137137
<skip>true</skip>
138138
</configuration>

0 commit comments

Comments
 (0)