This application includes a Lambda with an SQS queue as an event source. You can find deployment scripts using Terraform that are configured to deploy this sample app to AWS Lambda while publishing and using the OpenTelemetry layers.
- Java for building this repository
- Terraform
- AWS credentials, either using environment variables or via the CLI and
aws configure
First, in the java subfolder of this repository, build all the artifacts.
./gradlew build
Then, decide if you want to try the wrapper or the agent version. Navigate to the appropriate subfolder of deploy and deploy with Terraform.
terraform init
terraform apply
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 that spans are logged in the CloudWatch logs for the function on the AWS Console either for the wrapper or for the agent.
If you already have an SQS queue to test with, uncomment the commented sections at the bottom of the main.tf and variables.tf files and then provide the ARN for your queue when running terraform apply. You will then need to publish a message to the queue to test the Lambda function.