@Override public T call() throws Exception { taskPendingStats.registerSuccessfulEvent(MathUtils.elapsedNanos(initNanos), TimeUnit.NANOSECONDS); long startNanos = MathUtils.nowInNano(); try { return this.callable.call(); } finally { long elapsedMicroSec = MathUtils.elapsedMicroSec(startNanos); taskExecutionStats.registerSuccessfulEvent(elapsedMicroSec, TimeUnit.MICROSECONDS); if (elapsedMicroSec >= warnTimeMicroSec) { log.warn("Callable {}:{} took too long {} micros to execute.", callable, callable.getClass(), elapsedMicroSec); } } } }
@Override public void run() { taskPendingStats.registerSuccessfulEvent(MathUtils.elapsedNanos(initNanos), TimeUnit.NANOSECONDS); long startNanos = MathUtils.nowInNano(); try { this.runnable.run(); } finally { long elapsedMicroSec = MathUtils.elapsedMicroSec(startNanos); taskExecutionStats.registerSuccessfulEvent(elapsedMicroSec, TimeUnit.MICROSECONDS); if (elapsedMicroSec >= warnTimeMicroSec) { log.warn("Runnable {}:{} took too long {} micros to execute.", runnable, runnable.getClass(), elapsedMicroSec); } } } }
@Override public void onClose(Status status, Metadata trailers) { stats.recordClientHandled(status.getCode()); if (stats.shouldRecordLatency()) { long latencyMicros = MathUtils.elapsedMicroSec(startNanos); stats.recordLatency(Status.OK == status, latencyMicros); } super.onClose(status, trailers); }
@Override public void close(Status status, Metadata trailers) { stats.recordServerHandled(status.getCode()); if (stats.shouldRecordLatency()) { long latencyMicros = MathUtils.elapsedMicroSec(startNanos); stats.recordLatency(Status.OK == status, latencyMicros); } super.close(status, trailers); } }