Using CodeGuru Profiler with your Lambda function
You can use Amazon CodeGuru Profiler to gain insights into runtime performance of your Lambda functions. This page describes how to activate CodeGuru Profiler from the Lambda console.
Sections
Supported runtimes
You can activate CodeGuru Profiler from the Lambda console if your function's runtime is Python3.8, Python3.9, Java 8 with Amazon Linux 2, or Java 11. For additional runtime versions, you can activate CodeGuru Profiler manually.
For Java runtimes, see Profiling your Java applications that run on AWS Lambda.
For Python runtimes, see Profiling your Python applications that run on AWS Lambda.
Note
CodeGuru Profiler currently only supports functions that use x86_64 architecture.
Activating CodeGuru Profiler from the Lambda console
This section describes how to activate CodeGuru Profiler from the Lambda console.
To activate CodeGuru Profiler from the Lambda console
Open the Functions page
of the Lambda console. -
Choose your function.
-
Choose the Configuration tab.
-
On the Monitoring and operations tools pane, choose Edit.
-
Under Amazon CodeGuru Profiler, turn on Code profiling.
-
Choose Save.
After activation, CodeGuru automatically creates a profiler group with the name aws-lambda-<your-function-name>
. You can change the name from the CodeGuru console.
What happens when you activate CodeGuru Profiler from the Lambda console?
When you activate CodeGuru Profiler from the console, Lambda automatically does the following on your behalf:
-
Lambda adds a CodeGuru Profiler layer to your function. For more details, see Use AWS Lambda layers in the Amazon CodeGuru Profiler User Guide.
-
Lambda also adds environment variables to your function. The exact value varies based on the runtime.
Environment variablesRuntimes Key Value java8.al2, java11
JAVA_TOOL_OPTIONS
-javaagent:/opt/codeguru-profiler-java-agent-standalone.jar
python3.8, python3.9
AWS_LAMBDA_EXEC_WRAPPER
/opt/codeguru_profiler_lambda_exec
-
Lambda adds the
AmazonCodeGuruProfilerAgentAccess
policy to your function's execution role.
Note
When you deactivate CodeGuru Profiler from the console, Lambda automatically removes the CodeGuru Profiler layer from your function.
However, Lambda does not remove the environment variables or the AmazonCodeGuruProfilerAgentAccess
policy
from your execution role.
What's next?
-
Learn more about the data collected by your profiler group in Working with visualizations in the Amazon CodeGuru Profiler User Guide.