AWS Lambda Native Tracing for Python

You can set up Instana AWS Lambda tracing for AWS Lambda functions written in Python.

For more information, see AWS Lambda tracing.

Supported Runtimes

  • Python 3.13
  • Python 3.12
  • Python 3.11
  • Python 3.10
  • Python 3.9

Starting from 14 October 2024, AWS Lambda no longer applies security patches and other updates to the Python 3.8 runtime that is used by Lambda functions. The functions that use Python 3.8 are no longer eligible for technical support, and you can no longer create new Lambda functions that use the Python 3.8 runtime.

Prerequisites

Set up the AWS agent for Lambda monitoring to collect versions and runtime metrics that Instana cannot collect from inside the AWS Lambda runtime.

Configuring AWS Lambda functions

You can enable tracing of Lambda functions by Installing the instana package manually.

Complete the following steps:

  1. Add the Instana Python Tracer package as a dependency to your function project. For more information, see the AWS Lambda documentation to create a .zip deployment package with dependencies.

  2. Set the Lambda handler to instana.lambda_handler.

    1. On the function configuration page, go to the Runtime settings section, and click Edit.

    Edit runtime settings
    Figure 1. Edit runtime settings

    1. In the Handler field, insert instana.lambda_handler and click Save.

    Save runtime settings
    Figure 2. Save runtime settings

    1. If you are using a custom handler value (instead of the default handler for your runtime, see preceding details), specify your handler in the environment variable LAMBDA_HANDLER to notify your Lambda Layer. For example, if your handler is myModule.myHandler, set the environment variable LAMBDA_HANDLER to myModule.myHandler. For other environment variables that need to be set, see the next section.
  3. Configure the following environment variables for the Lambda function:

    • INSTANA_ENDPOINT_URL: 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.
    • LAMBDA_HANDLER: Your custom handler, if you are not using the default handler lambda_function.lambda_handler.