aws / aws-lambda-dotnet

Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Apache License 2.0
1.57k stars 479 forks source link

Support extending Amazon.Lambda.AspNetCoreServer.Hosting handler #1551

Open blytheaw opened 1 year ago

blytheaw commented 1 year ago

Describe the feature

Provide some way to annotate or wrap the abstracted handler provided by Amazon.Lambda.AspNetCoreServer.Hosting so that third party tooling that requires interaction with the handler can be used.

Use Case

Many observability and utility tools for .NET (OpenTelemetry and AWS Lambda Powertools to name the most prominent) require either directly wrapping the Lambda handler or adding annotations to it.

Proposed Solution

Some kind of override or extension method that would allow for slapping annotations or boilerplate around the handler without sacrificing the convenience of Amazon.Lambda.AspNetCoreServer.Hosting. Maybe a delegate in the registration method (AddAWSLambdaHosting) to allow adding some arbitrary code executed before the handler.

Other Information

Amazon.Lambda.AspNetCoreServer.Hosting is an amazing package and solution that lowers the barrier to entry for moving non-serverless .NET APIs to AWS Lambda with very little overhead. I'm excited about this because it can help increase adoption of serverless in my teams and be less intimidating.

However, we need to be able to use observability tooling to go to production, and this is the only real show-stopper for us.

I'm not totally against using the less abstracted method with LambdaEntryPoint / LocalEntryPoint but we've already consolidated Program.cs and Startup.cs using the minimal API startup model and we would have to undo that in all of our services to revert back to this pattern.

Acknowledgements

AWS .NET SDK and/or Package version used

Amazon.Lambda.AspNetCoreServer.Hosting

Targeted .NET Platform

.NET 6

Operating System and version

Any

ashishdhingra commented 1 year ago

Needs review with the team. CC @normj

normj commented 1 year ago

@ashishdhingra I know about this issue from other conversation channels and this is an important issue for us to figure out how to squeeze in.

Tychus commented 2 months ago

Any update on this ? recently created a lambda web api project and i'm unable to use any sort of metric Open telemtry or Powertools.