aws / aws-lambda-go

Libraries, samples and tools to help Go developers develop AWS Lambda functions.
Apache License 2.0
3.58k stars 548 forks source link

Plumb error info to X-ray #544

Closed bmoffatt closed 5 months ago

bmoffatt commented 6 months ago

Issue #, if available:

None

Description of changes:

This change fixes a divergence in behavior between the go1.x runtime, and the provided.XYZ runtime family. In go1.x, the github.com/aws/aws-lambda-go/messages/InvokeResponse_Error struct is wrapped in a certain way and then presented to the AWS X-Ray services in Lambda's default trace documents. In the Lambda Runtime API, this structure is passed as the Lambda-Runtime-Function-Xray-Error-Cause header.

Lambda's Java Runtime Interface Client is one public reference of this behavior. https://github.com/aws/aws-lambda-java-libs/blob/3d8dfb66f3a852bf69618bd5f66222692f1f5a49/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/AWSLambda.java#L264


When X-Ray is enabled for a function, this populates the "Exceptions" tab when viewing a trace.

Screenshot 2024-01-24 at 9 27 19 AM

For reference, here's what the tab renders for a go1.x function.

Screenshot 2024-01-24 at 9 29 52 AM

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

codecov-commenter commented 6 months ago

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (3a93ed1) 72.95% compared to head (7ba157c) 73.30%.

Files Patch % Lines
lambda/invoke_loop.go 85.71% 2 Missing and 2 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #544 +/- ## ========================================== + Coverage 72.95% 73.30% +0.34% ========================================== Files 26 26 Lines 1457 1487 +30 ========================================== + Hits 1063 1090 +27 - Misses 322 324 +2 - Partials 72 73 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.