core: include how long deadline was in Status message

This commit is contained in:
Carl Mastrangelo 2017-05-31 15:04:10 -07:00 committed by GitHub
parent 7b97df04d3
commit 104350cf2e
1 changed files with 11 additions and 3 deletions

View File

@ -292,18 +292,26 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT>
} }
private class DeadlineTimer implements Runnable { private class DeadlineTimer implements Runnable {
private final long remainingNanos;
DeadlineTimer(long remainingNanos) {
this.remainingNanos = remainingNanos;
}
@Override @Override
public void run() { public void run() {
// DelayedStream.cancel() is safe to call from a thread that is different from where the // DelayedStream.cancel() is safe to call from a thread that is different from where the
// stream is created. // stream is created.
stream.cancel(DEADLINE_EXCEEDED); stream.cancel(DEADLINE_EXCEEDED.augmentDescription(
String.format("deadline exceeded after %dns", remainingNanos)));
} }
} }
private ScheduledFuture<?> startDeadlineTimer(Deadline deadline) { private ScheduledFuture<?> startDeadlineTimer(Deadline deadline) {
long remainingNanos = deadline.timeRemaining(TimeUnit.NANOSECONDS);
return deadlineCancellationExecutor.schedule( return deadlineCancellationExecutor.schedule(
new LogExceptionRunnable(new DeadlineTimer()), deadline.timeRemaining(TimeUnit.NANOSECONDS), new LogExceptionRunnable(
TimeUnit.NANOSECONDS); new DeadlineTimer(remainingNanos)), remainingNanos, TimeUnit.NANOSECONDS);
} }
@Nullable @Nullable