Skip to content

Commit 441d0a5

Browse files
authored
Configure java runtime in the sample apps (#1276)
* Configure java runtime in the sample apps * Update readme
1 parent 70db465 commit 441d0a5

File tree

13 files changed

+59
-5
lines changed

13 files changed

+59
-5
lines changed

java/sample-apps/aws-sdk/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ terraform init
2424
terraform apply
2525
```
2626

27+
Use the following command to configure runtime and architecture
28+
29+
```
30+
TF_VAR_architecture=x86_64 \
31+
TF_VAR_runtime=java11 \
32+
terraform apply -auto-approve
33+
```
34+
2735
For the agent version, to change the configuration of the OpenTelemetry collector, you can provide the ARN of a Lambda layer with a custom collector configuration in a file named `config.yaml` when prompted after running the `terraform apply` command.
2836

2937
After deployment, a URL which can be used to invoke the function via API Gateway will be displayed. The agent version

java/sample-apps/aws-sdk/deploy/agent/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module "hello-lambda-function" {
55
architectures = compact([var.architecture])
66
function_name = var.name
77
handler = "io.opentelemetry.lambda.sampleapps.awssdk.AwsSdkRequestHandler::handleRequest"
8-
runtime = "java11"
8+
runtime = var.runtime
99

1010
create_package = false
1111
local_existing_package = "${path.module}/../../build/libs/aws-sdk-all.jar"

java/sample-apps/aws-sdk/deploy/agent/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ variable "architecture" {
3232
description = "Lambda function architecture, valid values are arm64 or x86_64"
3333
default = "x86_64"
3434
}
35+
36+
variable "runtime" {
37+
type = string
38+
description = "java agent runtime used for sample Lambda Function"
39+
default = "java11"
40+
}

java/sample-apps/aws-sdk/deploy/wrapper/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module "hello-lambda-function" {
55
architectures = compact([var.architecture])
66
function_name = var.name
77
handler = "io.opentelemetry.lambda.sampleapps.awssdk.AwsSdkRequestHandler::handleRequest"
8-
runtime = "java11"
8+
runtime = var.runtime
99

1010
create_package = false
1111
local_existing_package = "${path.module}/../../build/libs/aws-sdk-all.jar"

java/sample-apps/aws-sdk/deploy/wrapper/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ variable "architecture" {
2727
description = "Lambda function architecture, valid values are arm64 or x86_64"
2828
default = "x86_64"
2929
}
30+
31+
variable "runtime" {
32+
type = string
33+
description = "java wrapper runtime used for sample Lambda Function"
34+
default = "java11"
35+
}

java/sample-apps/okhttp/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ terraform init
3636
terraform apply
3737
```
3838

39+
Use the following command to configure runtime and architecture
40+
41+
```
42+
TF_VAR_architecture=x86_64 \
43+
TF_VAR_runtime=java11 \
44+
terraform apply -auto-approve
45+
```
46+
3947
After deployment, a URL which can be used to invoke the function via API Gateway will be displayed. As it uses the
4048
wrapper, it tends to take 5-10s. Confirm that spans are logged in the CloudWatch logs for the function on the AWS Console for the
4149
[wrapper](https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logsV2:log-groups/log-group/$252Faws$252Flambda$252Fhello-awssdk-java-wrapper).n

java/sample-apps/okhttp/deploy/wrapper/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module "hello-lambda-function" {
55
architectures = compact([var.architecture])
66
function_name = var.name
77
handler = "io.opentelemetry.lambda.sampleapps.okhttp.OkHttpRequestHandler::handleRequest"
8-
runtime = "java11"
8+
runtime = var.runtime
99

1010
create_package = false
1111
local_existing_package = "${path.module}/../../build/libs/okhttp-all.jar"

java/sample-apps/okhttp/deploy/wrapper/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ variable "architecture" {
2727
description = "Lambda function architecture, valid values are arm64 or x86_64"
2828
default = "x86_64"
2929
}
30+
31+
variable "runtime" {
32+
type = string
33+
description = "java runtime used for sample Lambda Function"
34+
default = "java11"
35+
}

java/sample-apps/sqs/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ terraform init
2323
terraform apply
2424
```
2525

26+
Use the following command to configure runtime and architecture
27+
28+
```
29+
TF_VAR_architecture=x86_64 \
30+
TF_VAR_runtime=java11 \
31+
terraform apply -auto-approve
32+
```
33+
2634
For the agent version, to change the configuration of the OpenTelemetry collector, you can provide the ARN of a Lambda layer with a custom collector configuration in a file named `config.yaml` when prompted after running the `terraform apply` command.
2735

2836
After deployment, login to AWS and test the Lambda function using the predefined SQS test payload. The agent version tends to take 10-20s for the first request, while the wrapper version tends to take 5-10s. Confirm

java/sample-apps/sqs/deploy/agent/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module "hello-lambda-function" {
55
architectures = compact([var.architecture])
66
function_name = var.name
77
handler = "io.opentelemetry.lambda.sampleapps.sqs.SqsRequestHandler::handleRequest"
8-
runtime = "java11"
8+
runtime = var.runtime
99

1010
create_package = false
1111
local_existing_package = "${path.module}/../../build/libs/sqs-all.jar"

java/sample-apps/sqs/deploy/agent/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ variable "architecture" {
3838
# type = string
3939
# description = "ARN for the SQS queue to use an event source for the Lambda"
4040
# }
41+
42+
variable "runtime" {
43+
type = string
44+
description = "java runtime used for sample Lambda Function"
45+
default = "java11"
46+
}

java/sample-apps/sqs/deploy/wrapper/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module "hello-lambda-function" {
55
architectures = compact([var.architecture])
66
function_name = var.name
77
handler = "io.opentelemetry.lambda.sampleapps.sqs.SqsRequestHandler::handleRequest"
8-
runtime = "java11"
8+
runtime = var.runtime
99

1010
create_package = false
1111
local_existing_package = "${path.module}/../../build/libs/sqs-all.jar"

java/sample-apps/sqs/deploy/wrapper/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ variable "architecture" {
3333
# type = string
3434
# description = "ARN for the SQS queue to use an event source for the Lambda"
3535
# }
36+
37+
variable "runtime" {
38+
type = string
39+
description = "java runtime used for sample Lambda Function"
40+
default = "java11"
41+
}

0 commit comments

Comments
 (0)