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

  • JVM 1.8.152–19


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 agent 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
af-south-1 arn:aws:lambda:ap-northeast-1:410797082306:layer:instana-java:74
ap-east-1 arn:aws:lambda:ap-east-1:410797082306:layer:instana-java:1
ap-northeast-1 arn:aws:lambda:ap-northeast-1:410797082306:layer:instana-java:74
ap-northeast-2 arn:aws:lambda:ap-northeast-2:410797082306:layer:instana-java:72
ap-northeast-3 arn:aws:lambda:ap-northeast-3:410797082306:layer:instana-java:1
ap-south-1 arn:aws:lambda:ap-south-1:410797082306:layer:instana-java:72
ap-south-2 arn:aws:lambda:ap-south-2:410797082306:layer:instana-java:1
ap-southeast-1 arn:aws:lambda:ap-southeast-1:410797082306:layer:instana-java:72
ap-southeast-2 arn:aws:lambda:ap-southeast-2:410797082306:layer:instana-java:72
ap-southeast-3 arn:aws:lambda:ap-southeast-3:410797082306:layer:instana-java:1
ap-southeast-4 arn:aws:lambda:ap-southeast-4:410797082306:layer:instana-java:1
ca-central-1 arn:aws:lambda:ca-central-1:410797082306:layer:instana-java:72
`cn-north-1' arn:aws-cn:lambda:cn-north-1:107998019096:layer:instana-java:1
`cn-northwest-1' arn:aws-cn:lambda:cn-northwest-1:107998019096:layer:instana-java:1
eu-central-1 arn:aws:lambda:eu-central-1:410797082306:layer:instana-java:72
eu-central-2 arn:aws:lambda:eu-central-2:410797082306:layer:instana-java:1
eu-north-1 arn:aws:lambda:eu-north-1:410797082306:layer:instana-java:72
eu-south-1 arn:aws:lambda:eu-south-1:410797082306:layer:instana-java:1
eu-south-2 arn:aws:lambda:eu-south-2:410797082306:layer:instana-java:1
eu-west-1 arn:aws:lambda:eu-west-1:410797082306:layer:instana-java:72
eu-west-2 arn:aws:lambda:eu-west-2:410797082306:layer:instana-java:72
eu-west-3 arn:aws:lambda:eu-west-3:410797082306:layer:instana-java:72
il-central-1 arn:aws:lambda:il-central-1:410797082306:layer:instana-java:1
me-central-1 arn:aws:lambda:me-central-1:410797082306:layer:instana-java:1
me-south-1 arn:aws:lambda:me-south-1:410797082306:layer:instana-java:1
sa-east-1 arn:aws:lambda:sa-east-1:410797082306:layer:instana-java:72
us-east-1 arn:aws:lambda:us-east-1:410797082306:layer:instana-java:72
us-east-2 arn:aws:lambda:us-east-2:410797082306:layer:instana-java:72
us-west-1 arn:aws:lambda:us-west-1:410797082306:layer:instana-java:72
us-west-2 arn:aws:lambda:us-west-2:410797082306:layer:instana-java:72

The pattern is arn:aws:lambda:${region}:410797082306:layer:instana-java:${layer-version} (or arn:aws-cn:lambda:${region}:107998019096:layer:instana-java:${layer-version} for AWS regions in China).

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.


Refer to the Additional configuration for the Instana Lambda tracers for an overview of the of environment-based settings for the Instana applicable to AWS Lambda functions.