private static AutoBalancerMetrics toAutoBalancerMetric(long nowMs,
                                                            int brokerId,
                                                            String brokerRack,
                                                            String name,
                                                            Map<String, String> tags,
                                                            double value,
                                                            String attribute) {
        String topic = tags.get(TOPIC_KEY);
        String partitionStr = tags.get(PARTITION_KEY);
        int partition = -1;
        if (partitionStr != null) {
            try {
                partition = Integer.parseInt(partitionStr);
            } catch (NumberFormatException e) {
                return null;
            }
        }
        switch (name) {
            case BYTES_IN_PER_SEC:
                return bytesInToMetric(topic, partition, nowMs, brokerId, brokerRack, value);
            case BYTES_OUT_PER_SEC:
                return bytesOutToMetric(topic, partition, nowMs, brokerId, brokerRack, value);
            case SIZE:
                if (partition == -1) {
                    return null;
                }
                return new TopicPartitionMetrics(nowMs, brokerId, brokerRack, topic, partition).put(RawMetricTypes.PARTITION_SIZE, value);
            default:
                return null;
        }
    }
Build a AutoBalancerMetric object.

@param nowMs      The current time in milliseconds.
@param brokerId   Broker Id.
@param brokerRack Broker rack.
@param name       Name of the metric.
@param tags       Tags of the metric.
@param value      Metric value.
@param attribute  Metric attribute -- can be {@code null}.
@return A {@link AutoBalancerMetrics} object with the given properties.
core/src/main/java/kafka/autobalancer/metricsreporter/metric/MetricsUtils.java