Skip to content

Enhance MarshalRequest/InvokeFeatures to setup the IHttpRequestIdentifierFeature #1148

@brendonparker

Description

@brendonparker

Describe the feature

Enhance the Lambda to AspNetCore handoff to include either (or both) the AwsRequestId from the ILambdaContext and the TraceId from the LambdaContext.

Use Case

This will help log correlation with things like AWS X-Ray, or other AWS Logs that are capturing the RequestId.

Proposed Solution

  1. Enhance Amazon.Lambda.AspNetCoreServer.Internal.InvokeFeatures to implement Microsoft.AspNetCore.Http.Features.IHttpRequestIdentifierFeature.
  2. Enhance the various implementations of MarshallRequest to setup the IHttpRequestIdentifierFeature, specifying using the ILambdaContext.AwsRequestId.

Other Information

See linked discussion for the path I took to get here. I'm not certain which makes more sense to use, the AwsRequestId or the TraceId. May depend on if you are using AWS X-Ray. Perhaps configurable?

This may be considered a breaking change, as it will no longer use the dotnet-generated RequestId. However, I feel using the AwsRequestId is more correct.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS .NET SDK and/or Package version used

Amazon.Lambda.AspNetCoreServer.Hosting 1.0.0

Targeted .NET Platform

.NET Core 3.1, .NET 6

Operating System and version

Windows 10, OSX Mojave, Ubuntu, AmazonLinux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions