powertools-lambda-typescript icon indicating copy to clipboard operation
powertools-lambda-typescript copied to clipboard

Feature request: HTTP request/response annotations

Open revmischa opened this issue 3 years ago • 15 comments

Use case

I have a nextjs CDK construct with a simple APIGW lambda wrapper around nextjs. I want to annotate my traces with HTTP request and response metadata, e.g. "URL" and "method" and "status code"

I would like to use it here: https://github.com/jetbridge/cdk-nextjs/blob/main/assets/lambda/NextJsHandler.ts#L45

I'd like to see the status code, path, method, etc in xray: image

Solution/User Experience

Perhaps something like traceRequestResponseCycle in https://docs.aws.amazon.com/xray-sdk-for-nodejs/latest/reference/AWSXRay.html

Alternative solutions

Discussed on discord: https://discord.com/channels/1006478942305263677/1006527385409179678/1042309163818168380

Acknowledgment

revmischa avatar Nov 18 '22 18:11 revmischa

Hi @revmischa thank you for taking the time to open a feature request.

As I have briefly mentioned on Discord: at the moment we don't use any of the middleware features from aws-xray-sdk so I'm unsure on how it will behave with Tracer. With that said, a first cursory look at traceRequestResponseCycle's implementation suggests that the utility provides some syntactic sugar around segment manipulation/annotation, which bodes well for Powertools compatibility.

Before considering the feature and putting it into the backlog, I would like some investigation to take place to make a small PoC and understand the impact and compatibility of this feature with Powertools.

Like with all features, contributions are more than welcome, and in case this is left to the maintainers, having 👍 on the feature request will help increasing its priority in our backlog.

If anyone is interested in picking up this issue, please leave a comment below to express your interest and agree on next steps. The maintainers will be happy to support you with clearing doubts or questions on the scope and codebase.

dreamorosi avatar Nov 18 '22 18:11 dreamorosi

For my purposes a simpler version of this would be to let me manually set the HTTP path, method, status code directly on the segment. But I have no idea how to do this and couldn't find any documentation on how to manually set those attributes.

revmischa avatar Nov 21 '22 21:11 revmischa

this is https://www.npmjs.com/package/aws-xray-sdk-express feature, this is very useful when we are tracing some ip address or api URL in a easy way

kennethwkz-mm avatar Dec 29 '22 10:12 kennethwkz-mm

FYI @revmischa, I have been looking at the aws-sdk-for-nodejs implementation to see if I could find a way to make it work for Tracer without changes but didn't have much luck.

I'll keep looking, also using the example that was just posted above.

dreamorosi avatar Dec 29 '22 11:12 dreamorosi

This issue has not received a response in 2 weeks. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

github-actions[bot] avatar Feb 28 '23 00:02 github-actions[bot]

Please keep open

revmischa avatar Feb 28 '23 03:02 revmischa

This issue has not received a response in 2 weeks. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

github-actions[bot] avatar Mar 25 '23 00:03 github-actions[bot]