chia7712 commented on code in PR #21726:
URL: https://github.com/apache/kafka/pull/21726#discussion_r2936958792


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchMetricsManager.java:
##########
@@ -130,7 +127,7 @@ void recordPartitionLag(TopicPartition tp, long lag) {
         String name = partitionRecordsLagMetricName(tp);
         maybeRecordDeprecatedPartitionLag(name, tp, lag);
 
-        Sensor recordsLag = new SensorBuilder(metrics, name, () -> 
mkMap(mkEntry("topic", tp.topic()), mkEntry("partition", 
String.valueOf(tp.partition()))))
+        Sensor recordsLag = new SensorBuilder(metrics, name, () -> 
Map.of("topic", tp.topic(), "partition", String.valueOf(tp.partition())))

Review Comment:
   We should keep using mkMap here; otherwise, the tag order will change. Would 
you mind adding a brief comment to prevent accidental changes in the future?



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchMetricsManager.java:
##########
@@ -145,7 +142,7 @@ void recordPartitionLead(TopicPartition tp, long lead) {
         String name = partitionRecordsLeadMetricName(tp);
         maybeRecordDeprecatedPartitionLead(name, tp, lead);
 
-        Sensor recordsLead = new SensorBuilder(metrics, name, () -> 
mkMap(mkEntry("topic", tp.topic()), mkEntry("partition", 
String.valueOf(tp.partition()))))
+        Sensor recordsLead = new SensorBuilder(metrics, name, () -> 
Map.of("topic", tp.topic(), "partition", String.valueOf(tp.partition())))

Review Comment:
   ditto



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchMetricsManager.java:
##########
@@ -300,8 +297,8 @@ static Map<String, String> topicTags(String topic) {
 
     @Deprecated
     static Map<String, String> topicPartitionTags(TopicPartition tp) {
-        return mkMap(mkEntry("topic", tp.topic().replace('.', '_')),
-            mkEntry("partition", String.valueOf(tp.partition())));
+        return Map.of("topic", tp.topic().replace('.', '_'),

Review Comment:
   ditto



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/Fetch.java:
##########
@@ -48,8 +45,8 @@ public static <K, V> Fetch<K, V> forPartition(
     ) {
         Map<TopicPartition, List<ConsumerRecord<K, V>>> recordsMap = 
records.isEmpty()
                 ? new HashMap<>()

Review Comment:
   Should we use `Map.of` instead ?



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchMetricsManager.java:
##########
@@ -283,7 +280,7 @@ private static boolean shouldReportDeprecatedMetric(String 
topic) {
     }
 
     private MetricName partitionPreferredReadReplicaMetricName(TopicPartition 
tp) {
-        Map<String, String> metricTags = mkMap(mkEntry("topic", tp.topic()), 
mkEntry("partition", String.valueOf(tp.partition())));
+        Map<String, String> metricTags = Map.of("topic", tp.topic(), 
"partition", String.valueOf(tp.partition()));

Review Comment:
   ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to