@Override
    public void run() {
      Stopwatch sw = Stopwatch.createUnstarted();
      Map<String, GcTimes> gcTimesBeforeSleep = getGcTimes();
      Counter jvmPauseWarnCnt = Metrics.getOrCreateCounter(MetricsConstants.JVM_PAUSE_WARN);
      Counter jvmPauseInfoCnt = Metrics.getOrCreateCounter(MetricsConstants.JVM_PAUSE_INFO);
      Counter jvmExtraSleepCnt = Metrics.getOrCreateCounter(MetricsConstants.JVM_EXTRA_SLEEP);
      while (shouldRun) {
        sw.reset().start();
        try {
          Thread.sleep(SLEEP_INTERVAL_MS);
        } catch (InterruptedException ie) {
          return;
        }
        long extraSleepTime = sw.elapsed(TimeUnit.MILLISECONDS) - SLEEP_INTERVAL_MS;
        Map<String, GcTimes> gcTimesAfterSleep = getGcTimes();

        if (extraSleepTime > warnThresholdMs) {
          ++numGcWarnThresholdExceeded;
          LOG.warn(formatMessage(
            extraSleepTime, gcTimesAfterSleep, gcTimesBeforeSleep));
          if (jvmPauseWarnCnt != null) jvmPauseWarnCnt.inc();
        } else if (extraSleepTime > infoThresholdMs) {
          ++numGcInfoThresholdExceeded;
          LOG.info(formatMessage(
            extraSleepTime, gcTimesAfterSleep, gcTimesBeforeSleep));
          if (jvmPauseInfoCnt != null) jvmPauseInfoCnt.inc();
        }
        if (jvmExtraSleepCnt != null) jvmExtraSleepCnt.inc(extraSleepTime);
        totalGcExtraSleepTime += extraSleepTime;
        gcTimesBeforeSleep = gcTimesAfterSleep;
      }
    }
log INFO if we detect a pause longer than this threshold
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/JvmPauseMonitor.java