Adding LambdaInsightsExtension results in timeout with 'sam local invoke'
See original GitHub issueDescription:
After following the steps about enabling lambda insights, local execution of the lambda functions is no longer possible. As soon as one adds the Layer to the template, the functions time out. Removing the layer makes them work again.
Steps to reproduce:
Add the following to either the function, or the Globals->Function part of the template:
Layers:
- Fn::Sub: "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:12"
Observed result:
2020-12-09 18:18:40,546 | Resolving code path. Cwd=/Users/mvanbaak/dev/x/backend-api/.aws-sam/build, CodeUri=YEventsFunction
2020-12-09 18:18:40,547 | Resolved absolute path to code is /Users/mvanbaak/dev/x/backend-api/.aws-sam/build/YEventsFunction
2020-12-09 18:18:40,547 | Code /Users/mvanbaak/dev/x/backend-api/.aws-sam/build/YEventsFunction is not a zip/jar file
2020-12-09 18:18:40,547 | arn:aws:lambda:eu-central-1:580247275435:layer:LambdaInsightsExtension:12 is already cached. Skipping download
2020-12-09 18:18:40,585 | Requested to skip pulling images ...
2020-12-09 18:18:40,585 | Mounting /Users/mvanbaak/dev/x/backend-api/.aws-sam/build/YEventsFunction as /var/task:ro,delegated inside runtime container
2020-12-09 18:18:41,054 | Starting a timer for 20 seconds for function 'YEventsFunction'
START RequestId: c3840afc-5659-4b27-9300-2d2f5001cf58 Version: $LATEST
[INFO] 2020-12-09T17:18:47.465Z initializing xray middleware
2020-12-09 18:18:51,055 | Function 'YEventsFunction' timed out after 20 seconds
2020-12-09 18:18:51,814 | Container was not created. Skipping deletion
2020-12-09 18:18:51,814 | No response from invoke container for YEventsFunction
Done.
Expected result:
2020-12-09 18:26:44,594 | Resolving code path. Cwd=/Users/mvanbaak/dev/x/backend-api/.aws-sam/build, CodeUri=YEventsFunction
2020-12-09 18:26:44,594 | Resolved absolute path to code is /Users/mvanbaak/dev/x/backend-api/.aws-sam/build/YEventsFunction
2020-12-09 18:26:44,594 | Code /Users/mvanbaak/dev/x/backend-api/.aws-sam/build/YEventsFunction is not a zip/jar file
2020-12-09 18:26:44,630 | Requested to skip pulling images ...
2020-12-09 18:26:44,631 | Mounting /Users/mvanbaak/dev/x/backend-api/.aws-sam/build/YEventsFunction as /var/task:ro,delegated inside runtime container
2020-12-09 18:26:45,083 | Starting a timer for 20 seconds for function 'YEventsFunction'
START RequestId: 5dbc8420-3405-4a54-a32f-59667f370e64 Version: $LATEST
[INFO] 2020-12-09T17:26:51.164Z initializing xray middleware
... lambda function debug output ...
END RequestId: 5dbc8420-3405-4a54-a32f-59667f370e64
REPORT RequestId: 5dbc8420-3405-4a54-a32f-59667f370e64 Init Duration: 0.30 ms Duration: 10545.23 ms Billed Duration: 10600 ms Memory Size: 192 MB Max Memory Used: 192 MB
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: mac os 11.0.1 (20B29)
sam --version
: SAM CLI, version 1.13.1
Add --debug flag to command you are running
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Using the AWS SAM CLI to enable Lambda Insights on an ...
Lambda Insights data won't be available from local invocations because the runtime is restarted without a shutdown event. For more information, see Release...
Read more >Tag Archives: Lambda Layers - Noise
There are a number of ways to use container image layering to add the functionality of Lambda layers to your Lambda function container...
Read more >@aws-cdk/aws-lambda - npm
AWS Lambda functions have a default timeout of 3 seconds, ... grantInvoke will result in a resource-based policy being created.
Read more >@aws-cdk/aws-lambda-event-sources - Package Manager
You can use event source mappings to process items from a stream or queue in services that don't invoke Lambda functions directly. Lambda...
Read more >awslambda - Go Packages
Loads the function code from a local disk path. ... required to allow assets to add // metadata for tooling like SAM CLI...
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 Free
Top 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
A new version of the Lambda Insights Extension has been released which should resolve this issue:
arn:aws:lambda:<region>:580247275435:layer:LambdaInsightsExtension:14
. You can see the list of available versions here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-extension-versions.html#Lambda-Insights-extension-1.0.98.0. Until SAM CLI supports the logs API, the Lambda Insights extension will not be able to collect metrics from locally running functions.Hey question @sapessi, this seems to fail using
sam local start-api
. Tried with both layer versions 14 and 16.