aws / aws/aws-xray-sdk-node

Segment exceptions are not assigned an ID

Open
#473 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
280
Forks
157
PR merge metrics
No merged PRs in 30d

Description

## Summary

The [exception object documentation](https://docs.aws.amazon.com/xray/latest/devguide/xray-api-segmentdocuments.html#api-segmentdocuments-errors) 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](https://github.com/aws/aws-xray-sdk-node/blob/master/packages/core/lib/segments/attributes/captured_exception.js) 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](https://github.com/aws/aws-xray-sdk-java/blob/9b724620c126b05313f4c97d18853bbb469e9ba5/aws-xray-recorder-sdk-core/src/main/java/com/amazonaws/xray/strategy/DefaultThrowableSerializationStrategy.java#L93), [Python](https://github.com/aws/aws-xray-sdk-python/blob/894b419518e14b5cb2a75293ed4da17f87b2a7c0/aws_xray_sdk/core/models/throwable.py#L25)).

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](https://github.com/open-telemetry/opentelemetry-collector-contrib) result in a segfault in the collector when it tries to [read the ID](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/awsxrayreceiver/internal/translator/cause.go#L73).

## Proposed Solution

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

Contributor guide

Open the contributing guide

Research direction

The target is packages/core/lib/segments/attributes/captured_exception.js; start by reading the CapturedException constructor and comparing its serialized fields with the AWS X-Ray exception-object specification linked in the issue. Done means emitted exception objects include an ID while preserving their existing fields and conforming to the documented format.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, node.js
Domain
observability-sre
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.