aws/aws-xray-sdk-node

Segment exceptions are not assigned an ID

michaelskahn opened this issue · 1 comments

Summary

The exception object documentation describes the fields of exception objects in segments. According to this spec, "All fields are optional except id." This SDK doesn't set the ID property on exception objects, causing messages to be out of spec and cause downstream errors.

Details

The CapturedException class represents an exception in the SDK. Its constructor defines several of the specified fields, but does not assign an ID. This appears to be different behavior than the other X-Ray SDKs (Java, Python).

Exceptions objects created by this SDK look like:

"exceptions":[{"message":"Not Found","type":"Error","stack":[...],"remote":false}]

when they should (if I understand the docs) look like

"exceptions":[{"id": "abcdabcdabcdabcd", "message":"Not Found","type":"Error","stack":[...],"remote":false}]

One impact of this difference is that messages generated by this SDK and sent to the awsxray otel collector result in a segfault in the collector when it tries to read the ID.

Proposed Solution

Add an ID assignment to the CapturedException constructor, or somewhere else appropriate.

Hi @michaelskahn,

Thank you for raising this, we should be able to generate an ID the same way we do for segments and add it to the capturedException object. I will get out a PR.