In our application, we are currently creating subsegments for our asynchronous downstream calls, but from looking at the AWS X-Ray documentation it seems that they are embedded with the parent segment that is created for the main thread.
Every once in awhile, we will get the error, where the main thread completes, therefor the entire segment (with embedded subsegments) is then sent to the xray daemon all at once, but one of the subsegments (asynchronous) completes after this main thread completion and throws an error in our logs because the parent segment is already sent the data to xray daemon and is completed.
We are wanting to to create the subsegments so that they are sent to the x-ray daemon independently, so if the main thread completes before any of the other threads (subsegments) it will not matter.
It seems that this is possible reviewing the AWS Xray documentation, but I can't find out how to implement this in java. I am having a really hard time finding examples and resources online other than the aws documentation below.
https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html