From 99c56fc700ca6aa346d328cdd71aec6f7c99a51d Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Fri, 15 Nov 2019 20:34:54 -0600 Subject: [PATCH] HBASE-19450 Addendum Limit logging of chore execution time at INFO to once per 5 minutes. --- .../main/java/org/apache/hadoop/hbase/ScheduledChore.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ScheduledChore.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ScheduledChore.java index 78458d41c1..778fa25cb6 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ScheduledChore.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ScheduledChore.java @@ -82,6 +82,8 @@ public abstract class ScheduledChore implements Runnable { private final Stoppable stopper; private final MovingAverage timeMeasurement = new WindowMovingAverage(); + private static final long FIVE_MINUTES_IN_NANOS = TimeUnit.MINUTES.toNanos(5L); + private long lastLog = System.nanoTime(); interface ChoreServicer { /** @@ -191,8 +193,16 @@ public abstract class ScheduledChore implements Runnable { chore(); return null; }); - LOG.info(String.format("%s average execution time: %.2f ns.", getName(), - timeMeasurement.getAverageTime())); + if (LOG.isInfoEnabled()) { + if (System.nanoTime() - lastLog > FIVE_MINUTES_IN_NANOS) { + LOG.info("{} average execution time: {} ns.", getName(), + (long)(timeMeasurement.getAverageTime())); + lastLog = System.nanoTime(); + } else { + LOG.trace("{} average execution time: {} ns.", getName(), + (long)(timeMeasurement.getAverageTime())); + } + } } } catch (Throwable t) { if (LOG.isErrorEnabled()) LOG.error("Caught error", t); -- 2.16.1