You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/11/08 17:22:39 UTC

[GitHub] [kafka] splett2 commented on a change in pull request #11474: KAFKA-13354: Topic metrics count request rate inconsistently with other request metrics

splett2 commented on a change in pull request #11474:
URL: https://github.com/apache/kafka/pull/11474#discussion_r744934377



##########
File path: core/src/main/scala/kafka/server/ReplicaManager.scala
##########
@@ -953,6 +957,16 @@ class ReplicaManager(val config: KafkaConfig,
         }
       }
     }
+
+    requestedTopicSet.foreach { case topic =>
+      brokerTopicStats.topicStats(topic).totalProduceRequestRate.mark()
+    }

Review comment:
       nit: maybe something like
   `requestedTopics.map(brokerTopicStats.topicStats).foreach(_.totalProduceRequestRate.mark())`
   flows a bit better.

##########
File path: core/src/main/scala/kafka/server/ReplicaManager.scala
##########
@@ -894,9 +894,11 @@ class ReplicaManager(val config: KafkaConfig,
                                requiredAcks: Short,
                                requestLocal: RequestLocal): Map[TopicPartition, LogAppendResult] = {
     val traceEnabled = isTraceEnabled
+    val failedTopicSet = mutable.Set[String]()
     def processFailedRecord(topicPartition: TopicPartition, t: Throwable) = {
       val logStartOffset = onlinePartition(topicPartition).map(_.logStartOffset).getOrElse(-1L)
-      brokerTopicStats.topicStats(topicPartition.topic).failedProduceRequestRate.mark()
+      // Every time appending to a local log fails, collect the topic names into the set.
+      failedTopicSet.add(topicPartition.topic)
       brokerTopicStats.allTopicsStats.failedProduceRequestRate.mark()

Review comment:
       we would want this metric to be incremented once per request instead of once per TP.
   ditto for `totalProduceRequestRate`, `totalFetchRequestRate`, `failedFetchRequestRate`
   
   Otherwise the `allTopicsStats` will be inconsistent with the sum of individual topic stats.
   




-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org