From 79d2c3c62a3a448a9aae77f3e8a549438a9ad6bd Mon Sep 17 00:00:00 2001 From: Xuan-Zhang Gong Date: Thu, 19 Jun 2025 17:57:22 +0800 Subject: [PATCH] KAFKA-19406 Remove BrokerTopicStats#removeOldFollowerMetrics (#19962) BTW: whether we should rename `ReplicaManager#updateLeaderAndFollowerMetrics` Reviewers: Ken Huang , PoAn Yang , TengYao Chi , Lan Ding , Chia-Ping Tsai --- core/src/main/scala/kafka/server/ReplicaManager.scala | 4 +--- .../kafka/storage/log/metrics/BrokerTopicStats.java | 11 ----------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/core/src/main/scala/kafka/server/ReplicaManager.scala b/core/src/main/scala/kafka/server/ReplicaManager.scala index 7c1b13b798c..78268af5891 100644 --- a/core/src/main/scala/kafka/server/ReplicaManager.scala +++ b/core/src/main/scala/kafka/server/ReplicaManager.scala @@ -2201,9 +2201,7 @@ class ReplicaManager(val config: KafkaConfig, private def updateLeaderAndFollowerMetrics(newFollowerTopics: Set[String]): Unit = { val leaderTopicSet = leaderPartitionsIterator.map(_.topic).toSet newFollowerTopics.diff(leaderTopicSet).foreach(brokerTopicStats.removeOldLeaderMetrics) - - // remove metrics for brokers which are not followers of a topic - leaderTopicSet.diff(newFollowerTopics).foreach(brokerTopicStats.removeOldFollowerMetrics) + // Currently, there are no follower metrics that need to be updated. } protected[server] def maybeAddLogDirFetchers(partitions: Set[Partition], diff --git a/storage/src/main/java/org/apache/kafka/storage/log/metrics/BrokerTopicStats.java b/storage/src/main/java/org/apache/kafka/storage/log/metrics/BrokerTopicStats.java index 3c6f2f909e6..ba562219fa9 100644 --- a/storage/src/main/java/org/apache/kafka/storage/log/metrics/BrokerTopicStats.java +++ b/storage/src/main/java/org/apache/kafka/storage/log/metrics/BrokerTopicStats.java @@ -76,8 +76,6 @@ public class BrokerTopicStats implements AutoCloseable { topicMetrics.closeMetric(BrokerTopicMetrics.FAILED_PRODUCE_REQUESTS_PER_SEC); topicMetrics.closeMetric(BrokerTopicMetrics.TOTAL_PRODUCE_REQUESTS_PER_SEC); topicMetrics.closeMetric(BrokerTopicMetrics.PRODUCE_MESSAGE_CONVERSIONS_PER_SEC); - topicMetrics.closeMetric(BrokerTopicMetrics.REPLICATION_BYTES_OUT_PER_SEC); - topicMetrics.closeMetric(BrokerTopicMetrics.REASSIGNMENT_BYTES_OUT_PER_SEC); topicMetrics.closeMetric(RemoteStorageMetrics.REMOTE_COPY_BYTES_PER_SEC_METRIC.getName()); topicMetrics.closeMetric(RemoteStorageMetrics.REMOTE_FETCH_BYTES_PER_SEC_METRIC.getName()); topicMetrics.closeMetric(RemoteStorageMetrics.REMOTE_FETCH_REQUESTS_PER_SEC_METRIC.getName()); @@ -99,15 +97,6 @@ public class BrokerTopicStats implements AutoCloseable { } } - // This method only removes metrics only used for follower - public void removeOldFollowerMetrics(String topic) { - BrokerTopicMetrics topicMetrics = topicStats(topic); - if (topicMetrics != null) { - topicMetrics.closeMetric(BrokerTopicMetrics.REPLICATION_BYTES_IN_PER_SEC); - topicMetrics.closeMetric(BrokerTopicMetrics.REASSIGNMENT_BYTES_IN_PER_SEC); - } - } - public void removeMetrics(String topic) { BrokerTopicMetrics metrics = stats.remove(topic); if (metrics != null) {