public void close() {
      if (isOpen) {
        Long endTime = System.currentTimeMillis();
        synchronized(metrics) {
          Long num = metrics.incrementCounter(numCounter);
          Long time = metrics.incrementCounter(timeCounter, endTime - startTime);
          if (num != null && time != null) {
            metrics.set(avgTimeCounter, Double.valueOf(time.doubleValue() / num.doubleValue()));
          }
        }
      } else {
        LOG.warn("Scope named " + name + " is not open, cannot be closed.");
      }
      isOpen = false;
    }
Closes scope, and records the time taken
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/common/metrics/LegacyMetrics.java