Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support using with Amazon.Lambda.AspNetCoreServer.Hosting #360

Open
1 of 2 tasks
blytheaw opened this issue Jul 24, 2023 · 5 comments
Open
1 of 2 tasks
Labels
feature-request New or enhancements to existing features minimal-api ASP.NET minimal api with Powertools v2 v2 release

Comments

@blytheaw
Copy link

Use case

The minimal API model using Amazon.Lambda.AspNetCoreServer.Hosting is a great way to migrate an existing ASP .NET API to AWS Lambda. However, if one requires better observability, there are not a lot of great options. It would be great if I could use Powertools for logging and tracing while still using this simple hosting model.

If this is already possible, I was not able to find it in the docs. Please advise!

Solution/User Experience

A way to initialize the tracer, logger, and metrics in the standard startup / dependency injection model of .NET would be ideal, rather than having to annotate the handler method specifically. Since the handler itself is not exposed when using the minimal API hosting model, I can't find a way to initialize the tracer and logger.

Alternative solutions

No response

Acknowledgment

@blytheaw blytheaw added feature-request New or enhancements to existing features triage Pending triage from maintainers labels Jul 24, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 24, 2023

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #dotnet channel on our Powertools for AWS Lambda Discord: Invite link

@hjgraca
Copy link
Contributor

hjgraca commented Jul 25, 2023

Hi @blytheaw , thanks for opening an issue.
We have an example of using the startup approach with Powertools, you can find it here.
Let us know if that is what you are looking for.

@hjgraca hjgraca removed the triage Pending triage from maintainers label Jul 25, 2023
@blytheaw
Copy link
Author

@hjgraca Thanks for the reply. I did see that example, but that doesn't solve what I am looking to do. If you look at the example in the README for Amazon.Lambda.AspNetCoreServer.Hosting, you'll see that there is no exposed hander method or LambdaEntryPoint. It does set things up in Startup, but the package abstracts away the handler as it is creating a single Lambda function that handles the ASP .NET web API.

Since there is nothing to add the annotation to directly, I'm wondering if there is an alternative method to using Powertools with .NET Lambda using this model?

@kumaranbsundar
Copy link

We are using Minimal API's to host our REST API's in lambda as well. Because you only support method attribute binding we can't use the power tools with minimal api's at least the automatic request/response logging, tracing etc. What you need is to extract the logic from https://github.com/aws-powertools/powertools-lambda-dotnet/blob/develop/libraries/src/AWS.Lambda.Powertools.Logging/Logger.cs and expose it as a middleware, so that it can be attached to the builder pipeline when the app starts in which case it will be invoked on every request. Any plans to support that in the near future?

@hjgraca
Copy link
Contributor

hjgraca commented Aug 15, 2023

Hi @kumaranbsundar @blytheaw , we want to support as many .NET programming models as we can including ASP.NET minimal apis.
We will be discussing how we can achieve that in a timely manner, just bear in mind that although we would love to have even more features we have to prioritize work that is already in the pipeline with the resources we have, so this feature might take some time to be available, but from my personal view this is something I want to have available.
Thanks for supporting and using the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New or enhancements to existing features minimal-api ASP.NET minimal api with Powertools v2 v2 release
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants