void apply(ControllerMetadataMetrics metrics) {
        if (fencedBrokersChange != 0) {
            metrics.addToFencedBrokerCount(fencedBrokersChange);
        }
        if (activeBrokersChange != 0) {
            metrics.addToActiveBrokerCount(activeBrokersChange);
        }
        if (migratingZkBrokersChange != 0) {
            metrics.addToMigratingZkBrokerCount(migratingZkBrokersChange);
        }
        if (globalTopicsChange != 0) {
            metrics.addToGlobalTopicCount(globalTopicsChange);
        }
        if (globalPartitionsChange != 0) {
            metrics.addToGlobalPartitionCount(globalPartitionsChange);
        }
        if (offlinePartitionsChange != 0) {
            metrics.addToOfflinePartitionCount(offlinePartitionsChange);
        }
        if (partitionsWithoutPreferredLeaderChange != 0) {
            metrics.addToPreferredReplicaImbalanceCount(partitionsWithoutPreferredLeaderChange);
        }
    }
Apply these changes to the metrics object.
metadata/src/main/java/org/apache/kafka/controller/metrics/ControllerMetricsChanges.java