AWS Lambda Native Tracing for Java

This page covers the setup Instana AutoTrace for AWS Lambda functions written in Java and other Java Virtual Machine-based languages like Kotlin.

Supported Runtimes

  • java8.a12
  • java11

Installation

Note: This documentation explains how to set up the tracing of Lambda functions running inside the Java Virtual Machine. Ensure that you also have performed the setup of the AWS Sensor for Lambda monitoring to ensure the collection of necessary information about versions and some runtime metrics that Instana cannot collect from inside the AWS Lambda runtime.

To enable tracing of Java Virtual Machine-based Lambda functions, perform the following steps:

  1. Add the Instana Lambda layer to your function.

    1. In the configuration page for your Lambda function, click on the Layers box and then on Add a layer. layer
    2. In the popup that opens, select "Provide a layer version ARN" and copy and paste the ARN for the Instana Lambda Layer that matches your region; you can find the right ARN for the Instana Lambda Layer in the Instana Lambda Layers section. layer selection
  2. Configure Environment Variables. Add the following environment variables:

    • JAVA_TOOL_OPTIONS: Fixed value: -javaagent:/opt/instana/standalone-collector.jar.
    • INSTANA_ENDPOINT_URL: This is your serverless monitoring endpoint. Make sure to use the correct value for your region that starts with https://serverless-.
    • INSTANA_AGENT_KEY: Your agent key.

    You can also obtain the correct values for these environment variables by going to your Instana installation, click on "... More" -> "Agents" -> "Installing Instana Agents" -> Platform: "AWS" -> Technology: "AWS Lambda".

  3. Save the Lambda function definition. save

All the steps outlined above can be done either via the AWS web console or any of the usual AWS management tools, such as:

Here is an example aws CLI command that might serve as a starting point if you want to automate the Instana integration of your AWS Lambdas:

# Do not copy and paste this verbatim!
# It will overwrite any previously defined collection of layers and
# environment variables.
aws --region $YOUR_REGION lambda update-function-configuration \
  --function-name $YOUR_LAMBDA_FUNCTION_NAME \
  --layers $INSTANA_LAYER_ARN \
  --environment ""Variables={JAVA_TOOL_OPTIONS=-javaagent:/opt/instana/standalone-collector.jar, INSTANA_ENDPOINT_URL=... , INSTANA_AGENT_KEY=... , ...}""

Instana Lambda Layers

The ARNs of the latest version of the AWS Lambda layers for Java are the following, per region:

Region ARN
ap-northeast-1 arn:aws:lambda:ap-northeast-1:410797082306:layer:instana-java:73
ap-northeast-2 arn:aws:lambda:ap-northeast-2:410797082306:layer:instana-java:71
ap-south-1 arn:aws:lambda:ap-south-1:410797082306:layer:instana-java:71
ap-southeast-1 arn:aws:lambda:ap-southeast-1:410797082306:layer:instana-java:71
ap-southeast-2 arn:aws:lambda:ap-southeast-2:410797082306:layer:instana-java:71
ca-central-1 arn:aws:lambda:ca-central-1:410797082306:layer:instana-java:71
eu-central-1 arn:aws:lambda:eu-central-1:410797082306:layer:instana-java:71
eu-north-1 arn:aws:lambda:eu-north-1:410797082306:layer:instana-java:71
eu-west-1 arn:aws:lambda:eu-west-1:410797082306:layer:instana-java:71
eu-west-2 arn:aws:lambda:eu-west-2:410797082306:layer:instana-java:71
eu-west-3 arn:aws:lambda:eu-west-3:410797082306:layer:instana-java:71
sa-east-1 arn:aws:lambda:sa-east-1:410797082306:layer:instana-java:71
us-east-1 arn:aws:lambda:us-east-1:410797082306:layer:instana-java:71
us-east-2 arn:aws:lambda:us-east-2:410797082306:layer:instana-java:71
us-west-1 arn:aws:lambda:us-west-1:410797082306:layer:instana-java:71
us-west-2 arn:aws:lambda:us-west-2:410797082306:layer:instana-java:71

The pattern is arn:aws:lambda:${region}:410797082306:layer:instana-java:${layer-version}.

Please make sure to always use the latest versions and update the layer version you are using in regular intervals to benefit from new features and fixes that we provide when publishing a new version of the layer.

Configuration

Refer to the Additional Configuration for the Instana Lambda Tracers for an overview of the of environment-based settings for the Instana that applicable to AWS Lambda functions.