-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert the Redisson lock span into an async span #667
Conversation
|
||
RFuture<Object> future = (RFuture) ret; | ||
CompletableFuture<Object> completableFuture = future.toCompletableFuture(); | ||
completableFuture.whenCompleteAsync((res, ex) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, as you picked #whenCompleteAsync
, you can't guarantee the given execution(span#asyncFinish
) called in time. The execution time could be longer than expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, as you picked
#whenCompleteAsync
, you can't guarantee the given execution(span#asyncFinish
) called in time. The execution time could be longer than expected.
How about this
RFuture<Object> future = (RFuture) ret;
CompletableFuture<Object> completableFuture = future.toCompletableFuture();
CompletableFuture.runAsync(()->{
completableFuture.join();
span.asyncFinish();
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this simpler?
completableFuture.whenComplete((result, error) -> { span.asyncFinish(); });
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this simpler?
completableFuture.whenComplete((result, error) -> { span.asyncFinish(); });
Okay, I thought you mean the whenComplete
may not notify listener as soon, consequently, i choose join
method。so the question is the thread context change could cause another cost time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whenComplete
should be a sync call when the future completed. Isn't it? Am I getting anything wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the completableFuture whenCompleteAsync into whenComplete
CHANGES
log.Refer Can I get the real time cost of redisson? skywalking#11799