Skip to content

Commit

Permalink
Resolve merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgerring committed Oct 13, 2023
1 parent c5ced4f commit fc9f0ec
Show file tree
Hide file tree
Showing 20 changed files with 562 additions and 208 deletions.
8 changes: 4 additions & 4 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
</description>

<modules>
<module>powertools-examples-core/sam</module>
<module>powertools-examples-core/cdk/app</module>
<module>powertools-examples-core/cdk/infra</module>
<module>powertools-examples-core/serverless</module>
<module>powertools-examples-core-utilities/sam</module>
<module>powertools-examples-core-utilities/cdk/app</module>
<module>powertools-examples-core-utilities/cdk/infra</module>
<module>powertools-examples-core-utilities/serverless</module>
<module>powertools-examples-idempotency</module>
<module>powertools-examples-parameters</module>
<module>powertools-examples-serialization</module>
Expand Down
2 changes: 2 additions & 0 deletions examples/powertools-examples-batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<sdk.version>2.20.152</sdk.version>
<aspectj.version>1.9.20</aspectj.version>

</properties>

<dependencies>
Expand Down
4 changes: 3 additions & 1 deletion examples/powertools-examples-cloudformation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.amazon.lambda.examples</groupId>
<version>1.17.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<artifactId>powertools-examples-cloudformation</artifactId>
<packaging>jar</packaging>

Expand All @@ -16,6 +16,8 @@
<lambda.core.version>1.2.3</lambda.core.version>
<lambda.events.version>3.11.3</lambda.events.version>
<aws.sdk.version>2.20.162</aws.sdk.version>
<aspectj.version>1.9.20</aspectj.version>

</properties>
<dependencyManagement>
<dependencies>
Expand Down
10 changes: 5 additions & 5 deletions examples/powertools-examples-core-utilities/cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ For general information on the deployed example itself, you can refer to the par

## Configuration
CDK uses the following project structure:
- [app](app) - stores the source code of your application, which is similar between all examples
- [infra](infra) - stores the definition of your infrastructure
- [cdk.json](infra/cdk.json) - tells the CDK Toolkit how to execute your app
- [CdkApp](infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input
- [CdkStack](infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it.
- [app](./app) - stores the source code of your application, which is similar between all examples
- [infra](./infra) - stores the definition of your infrastructure
- [cdk.json](./infra/cdk.json) - tells the CDK Toolkit how to execute your app
- [CdkApp](./infra/src/main/java/cdk/CdkApp.java) - bootstraps your stack, taking AWS `account` and `region` as input
- [CdkStack](./infra/src/main/java/cdk/CdkStack.java) - defines the Lambda function to be deployed as well as API Gateway for it.

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.

Expand Down
147 changes: 70 additions & 77 deletions examples/powertools-examples-core-utilities/cdk/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.amazon.lambda.examples</groupId>
<!-- TODO TODO TODO this should build from SNAPSHOT, but it doesn't, because the snapshots
don't appear in the docker environment CDK builds it in in our CDK tests. How to procede? V2 blocker -->
<version>1.17.0</version>
<artifactId>powertools-examples-core-utilities-cdk</artifactId>
<packaging>jar</packaging>

<name>Powertools for AWS Lambda (Java) library Examples - Core Utilities (logging, tracing, metrics) with CDK</name>
<name>Powertools for AWS Lambda (Java) library Examples - Core</name>

<properties>
<log4j.version>2.20.0</log4j.version>
Expand Down Expand Up @@ -40,7 +41,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.2</version>
<version>3.11.3</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand All @@ -67,80 +68,72 @@
</dependencies>

<build>
<finalName>helloworld-lambda</finalName>
<plugins>
<plugin>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<complianceLevel>${maven.compiler.target}</complianceLevel>
<aspectLibraries>
<aspectLibrary>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-tracing</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-logging</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-metrics</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-transform-maven-shade-plugin-extensions</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>
</plugin>
<!-- Don't deploy the example -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<finalName>helloworld-lambda</finalName>
<plugins>
<plugin>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<complianceLevel>${maven.compiler.target}</complianceLevel>
<aspectLibraries>
<aspectLibrary>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-tracing</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-logging</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>software.amazon.lambda</groupId>
<artifactId>powertools-metrics</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-transform-maven-shade-plugin-extensions</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<profiles>
<!-- Use a profile to enforce AspectJ version 1.9.7 if we are Java 1.8 otherwise we'll get class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@
public class App implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
private final static Logger log = LogManager.getLogger(App.class);

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

Expand Down Expand Up @@ -87,25 +84,18 @@ public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEv
return response
.withStatusCode(200)
.withBody(output);
<<<<<<<< HEAD:examples/powertools-examples-core-utilities/cdk/app/src/main/java/helloworld/App.java
} catch (IOException e) {
========
} catch (RuntimeException | IOException e) {
>>>>>>>> main:examples/powertools-examples-core/serverless/src/main/java/helloworld/App.java
return response
.withBody("{}")
.withStatusCode(500);
}
}

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

========
>>>>>>>> main:examples/powertools-examples-core/serverless/src/main/java/helloworld/App.java
@Tracing(namespace = "getPageContents", captureMode = CaptureMode.DISABLED)
private String getPageContents(String address) throws IOException {
URL url = new URL(address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can also use `sam init` to create a new Gradle-powered Powertools applicatio
and then **Hello World Example with Powertools for AWS Lambda**, **Java 17** runtime, and finally **gradle**.


For general information on the deployed example itself, you can refer to the parent [README](../../powertools-examples-core/README.md)
For general information on the deployed example itself, you can refer to the parent [README](../README.md)

## Configuration
SAM uses [template.yaml](template.yaml) to define the application's AWS resources.
Expand Down
Loading

0 comments on commit fc9f0ec

Please sign in to comment.