static void deleteMetricsConnection(final String scope) {
    METRICS_INSTANCES.computeIfPresent(scope, (s, metricsConnection) -> {
      metricsConnection.decrConnectionCount();
      if (metricsConnection.getConnectionCount() == 0) {
        metricsConnection.shutdown();
        return null;
      }
      return metricsConnection;
    });
  }
This class is for maintaining the various connection statistics and publishing them through the
metrics interfaces. This class manages its own {@link MetricRegistry} and {@link JmxReporter} so
as to not conflict with other uses of Yammer Metrics within the client application. Calling
{@link #getMetricsConnection(Configuration, String, Supplier, Supplier)} implicitly creates and
"starts" instances of these classes; be sure to call {@link #deleteMetricsConnection(String)} to
terminate the thread pools they allocate. The metrics reporter will be shutdown
{@link #shutdown()} when all connections within this metrics instances are closed.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetricsConnection.java