Are there any tricks to get the
LambdaLogger to log the request id with every message? The closest I've gotten is by using scopes. This gives me a consistent ID for every message within a request, but this is not the actual
requestid that AWS generates (see below). I've tried turning on EventIDs, but this doesn't appear to do anything useful. I'm on Amazon.Lambda.Logging.AspNetCore 2.3.0.
START RequestId: 0398a3a7-a36f-47c4-acf8-62baf867b25c Version: $LATEST
I'm looking to have both of RequestIDs to be the GUID assigned by AWS.
Hi ... I get an error, while starting my application within the lambda testtool:
System.MissingMethodException: Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureAppConfiguration(System.Action`2<Microsoft.AspNetCore.Hosting.WebHostBuilderContext,Microsoft.Extensions.Configuration.IConfigurationBuilder>)'.
I have implemented a serverless lambda function which is to be invoked by API Gateway, but I am asked to use WebApi template. I don't understand how would choosing this template would be better. The api gateway SAM configuration any way takes care of hitting that lambda function. Besides, that lamda is simply responsible to insert data into a table.
Kindly enlighten me on questions above and the above scenario considering the best practices.
@normj - what's your thoughts on the following statements?
This page titled "Using Amazon Logging Frameworks with AWS Lambda" describes AWS Lambda logging patterns: https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/cw-log-frameworks.html
But, when you goto any of the links in the last line, "The AWS .NET logging plugins are a new open source project on GitHub. All of the plugins are there, including samples and instructions on how to configure CloudWatch Logs for each of the supported .NET logging frameworks.", they lead you to a project with a readme.md that reads "When using Lambda it is recommended to use either the ILambdaContext.Logger.LogLine or the Amazon.Lambda.Logging.AspNetCore package."
In other words, it seems the bulk of the page "https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/cw-log-frameworks.html" is bad advice, because it is demonstrating a pattern which is not recommended.
I feel as though I have wasted a couple of days because of this because I missed this callout in the readme.md not to use them with AWS Lambda. BTW, wasted days because I couldn't not figure out why the log events were not being written. Ironically, they do seem to get flushed with the next call to the lambda function, so the last set of entries is always missing.
Can anyone help me on
-- Custom Header not being added at final HTTP response - APIGatewayHttpApiV2ProxyResponse class from AWS .NET Lambda SDK
Severity Code Description Project File Line Suppression State Tool Error CS0234 The type or namespace name 'APIGatewayEvents' does not exist in the namespace 'Amazon.Lambda' (are you missing an assembly reference?) TableReadyAWSRestaurantsInfoLambda C:\Users\zhiwe\source\repos\TableReadyAWSRestaurantsInfoLambda\TableReadyAWSRestaurantsInfoLambda\Function.cs 7 Active Compiler
@hounddog22030 might seem weird, try increasing the memory available to the function. You get more CPU if you allocate more memory. It says so in the FAQs (but not the page that the FAQs link to for "more information")
My situation: With 128MB memory, first invocation takes 9 seconds(!!!!) and subsequent invocations take avg 600ms(!!!!), the function doesn't use more than 100MB memory, but setting to 384MB, first invocation takes <3 seconds and subsequent invocations take avg 60ms. So on a GB-second basis it costs 1/3rd as much to run with 384MB allocated, and the function completes within a reasonable time. (600ms is not a reasonable time for an API!)
It's no wonder stuff runs like a dog with 128MB memory:
Lambda allocates CPU power in proportion to the amount of memory configured. Memory is the amount of memory available to your Lambda function at runtime. You can increase or decrease the memory and CPU power allocated to your function using the Memory (MB) setting. To configure the memory for your function, set a value between 128 MB and 10,240 MB in 1-MB increments. At 1,769 MB, a function has the equivalent of one vCPU (one vCPU-second of credits per second).