public void close() throws Exception {
    synchronized (metrics) {
      MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
      if (mbs.isRegistered(oname)) {
        mbs.unregisterMBean(oname);
      }
      metrics.clear();
      threadLocalScopes.remove();
    }
  }
Resets the static context state to initial.
Used primarily for testing purposes.

Note that threadLocalScopes ThreadLocal is *not* cleared in this call.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/common/metrics/LegacyMetrics.java