This page provides requirements and an overview of the instrumentation process for Python functions during development. The preferred method is to use the AppDynamics AWS Lambda Extension. See Use the AppDynamics AWS Lambda Extension to Instrument Serverless APM at Runtime.
This document contains links to Amazon Web Services (AWS) documentation. AppDynamics makes no representation as to the accuracy of Amazon documentation because Amazon controls its own documentation.
Before You Begin
Ensure that your setup meets the following requirements:
- Existing AWS Lambda functions implemented in Python >= 3.6
- Python Package Installer (the
pipversion must match the Python version of your AWS Lambda function)
- AppDynamics SaaS Controller >= 4.5.16
Install the Python Serverless Tracer
The Python Serverless Tracer is available for Python >= 3.6. The version of the tracer you obtain from PyPi needs to match the version of Python you use to run your function code in AWS.
The Python Serverless Tracer is available for download in PyPi repository. You can install the Python Serverless Tracer locally or package it with your AWS Lambda function code.
pip install command to install the tracer in your local environment:
pip install appdynamics-lambda-tracer
If you install the tracer locally, you need to package the tracer with your AWS Lambda function at runtime.
Package with AWS Lambda Functions
Run the following command to include the tracer in your function's package:
pip install --target ./package/ appdynamics-lambda-tracer
See AWS documentation to learn more about packaging dependencies in your functions.
Instrument Your Function Code
To instrument your AWS Lambda function, add these lines of code:
import appdynamics # Add AppDynamics libraries. Must be the first line of code @appdynamics.tracer # Must come before the handler function def my_handler(event, context): print("Hello world!")
Exit Call Instrumentation
By default, the Python Serverless Tracer automatically discovers HTTP, Amazon DynamoDB, and inter-AWS Lambda exit calls. Use the Python Tracer API to create an exit call if you want visibility into other types of external calls made by your function. See Python Serverless Tracer API.
This document contains links to AWS documentation. AppDynamics makes no representation as to the accuracy of Amazon documentation because Amazon controls its own documentation
Amazon Web Services, the AWS logo, AWS, and any other AWS Marks used in these materials are trademarks of Amazon.com, Inc. or its affiliates in the United States and/or other countries.