Using CodeGuru Profiler with your Lambda function - Amazon Lambda
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

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.

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, Java 11, or Java 17. For additional runtime versions, you can activate CodeGuru Profiler manually.

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
  1. Open the Functions page of the Lambda console.

  2. Choose your function.

  3. Choose the Configuration tab.

  4. On the Monitoring and operations tools pane, choose Edit.

  5. Under Amazon CodeGuru Profiler, turn on Code profiling.

  6. 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 Amazon 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 variables
    Runtimes 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.