@Override
    public synchronized void close() {
        if (closed) {
            log.trace("{}: gauge suite is already closed.", suiteName);
            return;
        }
        closed = true;
        int prevSize = 0;
        for (Iterator<StoredIntGauge> iter = gauges.values().iterator(); iter.hasNext(); ) {
            pending.push(new PendingMetricsChange(iter.next().metricName, null));
            prevSize++;
            iter.remove();
        }
        performPendingMetricsOperations();
        log.trace("{}: closed {} metric(s).", suiteName, prevSize);
    }
Perform pending metrics additions or removals.
It is important to perform them in order.  For example, we don't want to try
to remove a metric that we haven't finished adding yet.
clients/src/main/java/org/apache/kafka/common/metrics/internals/IntGaugeSuite.java