@Override
    public void close() {
        registry.ifPresent(r -> Arrays.asList(
            FENCED_BROKER_COUNT,
            ACTIVE_BROKER_COUNT,
            MIGRATING_ZK_BROKER_COUNT,
            GLOBAL_TOPIC_COUNT,
            GLOBAL_PARTITION_COUNT,
            OFFLINE_PARTITION_COUNT,
            PREFERRED_REPLICA_IMBALANCE_COUNT,
            METADATA_ERROR_COUNT,
            ZK_MIGRATION_STATE
        ).forEach(r::removeMetric));
    }
Create a new ControllerMetadataMetrics object.

@param registry The metrics registry, or Optional.empty if this is a test and we don't have one.
metadata/src/main/java/org/apache/kafka/controller/metrics/ControllerMetadataMetrics.java