(lambda): profiling python support
See original GitHub issueI am proposing adding a Resource for CodeGuru Lambda Layer. Currently when setting up Code Guru layer you will need to do something like this:
import lambda = require('@aws-cdk/aws-lambda');
const layerArn = `arn:aws:lambda:us-west-1:580247275435:layer:AWSCodeGuruProfilerJavaAgentLayer:3`;
const layer = lambda.LayerVersion.fromLayerVersionArn(this, `LayerFromArn`, layerArn);
I propose it should be more like:
new CodeGuruLayer(this, "CodeGuruLayer', {});
Use Case
- We wouldn’t need to hardcode arns anymore which leaves room for error
- The resource could by default use the latest version so that consumers would not need to keep track of what version they are using(we should still provide option to use any version through props)
- We can add the supported runtimes to the resource so that issues can be found at build time
- We can also add supported regions to the resource, to find issues at build time
Proposed Solution
Proposed solution could roughly look like this. This would require exporting LayerVersionBase from lambda module. Or maybe another abstract class is warranted. That abstract class could be used for other layers as well, such as the lambda insights layer.
export interface CodeGuruLayerProps {
readonly region: string;
readonly version?: number;
readonly compatibleRuntimes?: Runtime[];
}
export class CodeGuruLayer extends LayerVersionBase {
public static LATEST_VERSION = 3; // eslint-disable-line
public readonly layerVersionArn: string;
public readonly compatibleRuntimes?: Runtime[] = Runtime.ALL;
public constructor(scope: Construct, id: string, props: CodeGuruLayerProps) {
super(scope, id);
const version = props.version != undefined ? props.version : CodeGuruLayer.LATEST_VERSION;
if (version > CodeGuruLayer.LATEST_VERSION || version < 1) {
throw new Error(`Not a valid CodeGuru version: ${version}`);
}
this.layerVersionArn = `arn:aws:lambda:${props.region}:157417159150:layer:AWSCodeGuruProfilerJavaAgentLayer:${version}`;
}
}
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Profiling your applications that run on AWS Lambda
You can profile your Lambda functions running in Python if they are called often enough for CodeGuru Profiler to gather enough samples. CodeGuru...
Read more >AWS CDK — How to code profiling your Lambda functions ...
AWS CDK — How to code profiling your Lambda functions by enabling AWS CodeGuru for Python. If you want to code profiling on...
Read more >Improve the performance of Lambda applications ... - Noise
Afterwards, CodeGuru Profiler provides recommendations to help resolve ... CodeGuru Profiler on an AWS Lambda function written in Python.
Read more >How to Profile AWS Lambda Functions - Pyroscope
AWS lambda is a popular serverless computing service that allows you to write code in any language and run it on AWS.
Read more >Serverless Python profiler for AWS Lambda using AWS X-Ray
Last week at AWS re:Invest 2017, I decided to give a try to AWS X-Ray, the AWS Distributed tracing system. This service has...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would propose that we go one step further. If the runtime is Python and the the
profiling
property is set, we should just add the layer to the function.@jonnekaunisto - would that satisfy your requirement as well?
I seem to be experiencing a similar problem. CDK provisions the resources and configurations as per the prerequisites, and after confirming that the layer, env vars, and permissions are in place, the ProfilingGroup still remains in a Setup Required state. For reference, please find a snippet of my code below:
CDK
lambda handler: base.py
As far i can can deduce, it seems almost as if the agent in the layer is not running correctly, but please correct me if i am wrong. Otherwise, please let me know if there is any more information i can provide.