| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
The Lambda profiler extension allows you to profile your Java functions invoke by invoke, with high fidelity, and no code changes. It uses the async-profiler project to produce profiling data and automatically uploads the data as HTML flame graphs to S3.
This is an alpha release and not yet ready for production use. We're especially interested in early feedback on usability, features, performance, and compatibility. Please send feedback by opening a GitHub issue.
The profiler has been tested with Lambda managed runtimes for Java 17 and Java 21.
To use the profiler you need to
The above assumes you're using the ZIP deployment method with managed runtimes. If you deploy your functions as container images instead, you will need to include the profiler in your Dockerfile at /opt/extensions/ rather than using a Lambda layer.
The following Quick Start gives AWS CLI commands you can run to get started (MacOS/Linux). There are also examples using infrastructure as code for you to refer to.
Clone the repo
git clone https://github.com/aws/aws-lambda-java-libsBuild the extension
cd aws-lambda-java-libs/experimental/aws-lambda-java-profiler/extension
./build_layer.shRun the update-function.sh script which will create a new S3 bucket, Lambda layer and all the configuration required.
cd ..
./update-function.sh YOUR_FUNCTION_NAMEInvoke your function and review the flame graph in S3 using your browser.
| Name | Value |
|---|---|
| AWS_LAMBDA_PROFILER_RESULTS_BUCKET_NAME | Your unique bucket name |
| JAVA_TOOL_OPTIONS | -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -javaagent:/opt/profiler-extension.jar |
| Name | Default Value | Options |
|---|---|---|
| AWS_LAMBDA_PROFILER_START_COMMAND | start,event=wall,interval=1us | |
| AWS_LAMBDA_PROFILER_STOP_COMMAND | stop,file=%s,include=*AWSLambda.main,include=start_thread | file=%s is required |
| AWS_LAMBDA_PROFILER_DEBUG | false | true - to enable debug logging |
| AWS_LAMBDA_PROFILER_COMMUNICATION_PORT | 1234 | a valid port number |
In /src is the code for a Java agent. It's entry point AgentEntry.premain() is executed as the runtime starts up. The environment variable JAVA_TOOL_OPTIONS is used to specify which .jar file the agent is in. The MANIFEST.MF file is used to specify the pre-main class.
When the agent is constructed, it starts the profiler and registers itself as a Lambda extension for INVOKE request.
A new thread is created to handle calling /next and uploading the results of the profiler to S3. The bucket to upload the result to is configurable using an environment variable.
Contributions to improve the Java profiler extension are welcome. Please see CONTRIBUTING.md for more information on how to report bugs or submit pull requests.
Issues or contributions to the async-profiler itself should be submitted to that project.
If you discover a potential security issue in this project we ask that you notify AWS Security via our vulnerability reporting page. Please do not create a public GitHub issue.
This project has adopted the Amazon Open Source Code of Conduct. See CODE_OF_CONDUCT.md for more details.
This project is licensed under the Apache 2.0 License. It uses the following projects:
| Back | FazBrowse Home | New Git URL |