@Override public void safeRun() { taskPendingStats.registerSuccessfulEvent(initNanos, TimeUnit.NANOSECONDS); long startNanos = MathUtils.nowInNano(); this.runnable.safeRun(); long elapsedMicroSec = MathUtils.elapsedMicroSec(startNanos); taskExecutionStats.registerSuccessfulEvent(elapsedMicroSec, TimeUnit.MICROSECONDS); if (elapsedMicroSec >= warnTimeMicroSec) { logger.warn( "Runnable {}:{} took too long {} micros to execute.", new Object[] {runnable, runnable.getClass(), elapsedMicroSec}); } }
TimedRunnable(SafeRunnable runnable) { this.runnable = runnable; this.initNanos = MathUtils.nowInNano(); }