question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding LambdaInsightsExtension results in timeout with 'sam local invoke'

See original GitHub issue

Description:

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)

  1. OS: mac os 11.0.1 (20B29)
  2. sam --version: SAM CLI, version 1.13.1

Add --debug flag to command you are running

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jaredcnancecommented, Jan 15, 2021

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.

1reaction
iRoachiecommented, Dec 3, 2021

Hey question @sapessi, this seems to fail using sam local start-api. Tried with both layer versions 14 and 16.

START RequestId: 20d47312-ce5f-4bfb-9e3d-9df2ee5e43d4 Version: $LATEST
thread 'meter_probe' panicked at 'Unable to read /proc for agent process: InternalError(bug at /local/p4clients/pkgbuild-DbvKa/workspace/build/AWSLogsLambdaInsights/AWSLogsLambdaInsights-1.0.119.0/AL2012/DEV.STD.PTHREAD/build/private/cargo-home/registry/src/-895cc363aacb953e/procfs-0.7.9/src/process/stat.rs:300 (please report this procfs bug)
Internal Unwrap Error: Internal error: bug at /local/p4clients/pkgbuild-DbvKa/workspace/build/AWSLogsLambdaInsights/AWSLogsLambdaInsights-1.0.119.0/AL2012/DEV.STD.PTHREAD/build/private/cargo-home/registry/src/-895cc363aacb953e/procfs-0.7.9/src/lib.rs:285 (please report this procfs bug)
Internal Unwrap Error: NoneError)', src/inputs/memory.rs:59:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'attempt to divide by zero', src/inputs/memory.rs:44:32
END RequestId: 20d47312-ce5f-4bfb-9e3d-9df2ee5e43d4
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found