Can I force subsegments to be the direct child of a segment?
- Dominant language
- Java
- Stars
- 100
- Forks
- 100
- PR merge metrics
- No merged PRs in 30d
Description
I am writing an AWS Lambda function in Java that uses [Project Reactor](https://projectreactor.io/) and reactive programming paradigms. The methods that I want to trace return Mono or Flux, which is really just a promise to return something in the future. This means that the work isn't "done" when the method exits. Instead, the subsegment should be started when the method is called and ended when the Mono or Flux complete.
More importantly, though, work is being done parallel and any new subsegment should be a _direct_ child of the segment created by the Lambda runtime, and not a child of the "current" subsegment. Is there a way to specify this when creating a subsegment? I don't see that in AWSXRay. All of the methods to begin or create a subsegment ultimately use AWSXRayRecorder.beginSubsegment(String), which delegates the task to the context. In the case of LambdaSegmentContext anyway, the newly created subsegment only seems to be added directly to the segment when it is the first subsegment. After that, newly created subsegments are added as a child of the "current" subsegment.
With the way that subsegments are created by default, a graph of my trace would look like this, where S is the segment and 1, 2, 3, and 4 are the subsegments:
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
11111111111111111111111111111111111
222222222222222222222222222
33333333333333333
44444444
By comparison, if I were (am?) able to specify the segment as the parent, the work being done would be graphed more like this instead, which is how it's actually happening:
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
1111111
2222222222
33333333333333333
44444444
Contributor guide
Assessment
This issue has not been assessed yet.