Skip to content

Commit

Permalink
Configure java runtime in the sample apps (#1276)
Browse files Browse the repository at this point in the history
* Configure java runtime in the sample apps

* Update readme
  • Loading branch information
vasireddy99 authored Apr 25, 2024
1 parent 70db465 commit 441d0a5
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 5 deletions.
8 changes: 8 additions & 0 deletions java/sample-apps/aws-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ terraform init
terraform apply
```

Use the following command to configure runtime and architecture

```
TF_VAR_architecture=x86_64 \
TF_VAR_runtime=java11 \
terraform apply -auto-approve
```

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.

After deployment, a URL which can be used to invoke the function via API Gateway will be displayed. The agent version
Expand Down
2 changes: 1 addition & 1 deletion java/sample-apps/aws-sdk/deploy/agent/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module "hello-lambda-function" {
architectures = compact([var.architecture])
function_name = var.name
handler = "io.opentelemetry.lambda.sampleapps.awssdk.AwsSdkRequestHandler::handleRequest"
runtime = "java11"
runtime = var.runtime

create_package = false
local_existing_package = "${path.module}/../../build/libs/aws-sdk-all.jar"
Expand Down
6 changes: 6 additions & 0 deletions java/sample-apps/aws-sdk/deploy/agent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ variable "architecture" {
description = "Lambda function architecture, valid values are arm64 or x86_64"
default = "x86_64"
}

variable "runtime" {
type = string
description = "java agent runtime used for sample Lambda Function"
default = "java11"
}
2 changes: 1 addition & 1 deletion java/sample-apps/aws-sdk/deploy/wrapper/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module "hello-lambda-function" {
architectures = compact([var.architecture])
function_name = var.name
handler = "io.opentelemetry.lambda.sampleapps.awssdk.AwsSdkRequestHandler::handleRequest"
runtime = "java11"
runtime = var.runtime

create_package = false
local_existing_package = "${path.module}/../../build/libs/aws-sdk-all.jar"
Expand Down
6 changes: 6 additions & 0 deletions java/sample-apps/aws-sdk/deploy/wrapper/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ variable "architecture" {
description = "Lambda function architecture, valid values are arm64 or x86_64"
default = "x86_64"
}

variable "runtime" {
type = string
description = "java wrapper runtime used for sample Lambda Function"
default = "java11"
}
8 changes: 8 additions & 0 deletions java/sample-apps/okhttp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ terraform init
terraform apply
```

Use the following command to configure runtime and architecture

```
TF_VAR_architecture=x86_64 \
TF_VAR_runtime=java11 \
terraform apply -auto-approve
```

After deployment, a URL which can be used to invoke the function via API Gateway will be displayed. As it uses the
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
[wrapper](https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logsV2:log-groups/log-group/$252Faws$252Flambda$252Fhello-awssdk-java-wrapper).n
Expand Down
2 changes: 1 addition & 1 deletion java/sample-apps/okhttp/deploy/wrapper/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module "hello-lambda-function" {
architectures = compact([var.architecture])
function_name = var.name
handler = "io.opentelemetry.lambda.sampleapps.okhttp.OkHttpRequestHandler::handleRequest"
runtime = "java11"
runtime = var.runtime

create_package = false
local_existing_package = "${path.module}/../../build/libs/okhttp-all.jar"
Expand Down
6 changes: 6 additions & 0 deletions java/sample-apps/okhttp/deploy/wrapper/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ variable "architecture" {
description = "Lambda function architecture, valid values are arm64 or x86_64"
default = "x86_64"
}

variable "runtime" {
type = string
description = "java runtime used for sample Lambda Function"
default = "java11"
}
8 changes: 8 additions & 0 deletions java/sample-apps/sqs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ terraform init
terraform apply
```

Use the following command to configure runtime and architecture

```
TF_VAR_architecture=x86_64 \
TF_VAR_runtime=java11 \
terraform apply -auto-approve
```

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.

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
Expand Down
2 changes: 1 addition & 1 deletion java/sample-apps/sqs/deploy/agent/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module "hello-lambda-function" {
architectures = compact([var.architecture])
function_name = var.name
handler = "io.opentelemetry.lambda.sampleapps.sqs.SqsRequestHandler::handleRequest"
runtime = "java11"
runtime = var.runtime

create_package = false
local_existing_package = "${path.module}/../../build/libs/sqs-all.jar"
Expand Down
6 changes: 6 additions & 0 deletions java/sample-apps/sqs/deploy/agent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ variable "architecture" {
# type = string
# description = "ARN for the SQS queue to use an event source for the Lambda"
# }

variable "runtime" {
type = string
description = "java runtime used for sample Lambda Function"
default = "java11"
}
2 changes: 1 addition & 1 deletion java/sample-apps/sqs/deploy/wrapper/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module "hello-lambda-function" {
architectures = compact([var.architecture])
function_name = var.name
handler = "io.opentelemetry.lambda.sampleapps.sqs.SqsRequestHandler::handleRequest"
runtime = "java11"
runtime = var.runtime

create_package = false
local_existing_package = "${path.module}/../../build/libs/sqs-all.jar"
Expand Down
6 changes: 6 additions & 0 deletions java/sample-apps/sqs/deploy/wrapper/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ variable "architecture" {
# type = string
# description = "ARN for the SQS queue to use an event source for the Lambda"
# }

variable "runtime" {
type = string
description = "java runtime used for sample Lambda Function"
default = "java11"
}

0 comments on commit 441d0a5

Please sign in to comment.