You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Async
public void myAsync() {
CompletableFuture.supplyAsync(() -> {
try {
log.info("before thread ....");
Thread.sleep(3000);
log.info("after thread ....");
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
log.info("before returning result ....");
return "Result of the asynchronous computation";
}, SegmentContextExecutors.newSegmentContextExecutor());
}
The issue here is that API waits for 3 seconds to reply when using SegmentContextExecutors.newSegmentContextExecutor(), but if I remove the segment executor, the function run in the background successfully, but for sure I lose the segment logging.
So what should be done to fix this ?
Tech stack
Spring boot v.2.7.2
Java 11
Aws x-ray v.2.11.2
The text was updated successfully, but these errors were encountered:
XRay SDK does not support asyn scenario very well because Segment(Subsegment) and SegmentContext are not decoupled. So XRay SDK can handle async case child subsegment gets closed early than parent Segment, but is hard to handle async case child subsegment starts later than parent, or close later than parent.
Sorry that we know this issue for a long time but have no bandwidth working on it. Alternatively we recommend user move on to opentelemetry, it automatically covers async scenario in context.
I have an api like this
And myService.myAsync implementation like this
The issue here is that API waits for 3 seconds to reply when using SegmentContextExecutors.newSegmentContextExecutor(), but if I remove the segment executor, the function run in the background successfully, but for sure I lose the segment logging.
So what should be done to fix this ?
Tech stack
Spring boot v.2.7.2
Java 11
Aws x-ray v.2.11.2
The text was updated successfully, but these errors were encountered: