guozhangwang commented on a change in pull request #11149:
URL: https://github.com/apache/kafka/pull/11149#discussion_r698854001



##########
File path: 
clients/src/main/java/org/apache/kafka/clients/producer/internals/KafkaProducerMetrics.java
##########
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.clients.producer.internals;
+
+import org.apache.kafka.common.MetricName;
+import org.apache.kafka.common.metrics.Metrics;
+import org.apache.kafka.common.metrics.Sensor;
+import org.apache.kafka.common.metrics.stats.CumulativeSum;
+
+import java.util.Map;
+
+public class KafkaProducerMetrics implements AutoCloseable {
+
+    public static final String GROUP = "producer-metrics";
+    private static final String FLUSH = "flush";
+    private static final String TXN_INIT = "txn-init";
+    private static final String TXN_BEGIN = "txn-begin";
+    private static final String TXN_SEND_OFFSETS = "txn-send-offsets";
+    private static final String TXN_COMMIT = "txn-commit";
+    private static final String TXN_ABORT = "txn-abort";
+    private static final String TOTAL_TIME_SUFFIX = "-time-ns-total";
+
+    private final Map<String, String> tags;
+    private final Metrics metrics;
+    private final Sensor initTimeSensor;
+    private final Sensor beginTxnTimeSensor;
+    private final Sensor flushTimeSensor;
+    private final Sensor sendOffsetsSensor;
+    private final Sensor commitTxnSensor;
+    private final Sensor abortTxnSensor;
+
+    public KafkaProducerMetrics(Metrics metrics) {
+        this.metrics = metrics;
+        tags = this.metrics.config().tags();
+        flushTimeSensor = newLatencySensor(
+            FLUSH,
+            "Total time producer has spent in flush in nanoseconds."
+        );
+        initTimeSensor = newLatencySensor(
+            TXN_INIT,
+            "Total time producer has spent in initTransactions in nanoseconds."
+        );
+        beginTxnTimeSensor = newLatencySensor(
+            TXN_BEGIN,
+            "Total time producer has spent in beginTransaction in nanoseconds."
+        );
+        sendOffsetsSensor = newLatencySensor(
+            TXN_SEND_OFFSETS,
+            "Total time producer has spent in sendOffsetsToTransaction."

Review comment:
       nit: also add ` in nanoseconds`?

##########
File path: 
streams/src/main/java/org/apache/kafka/streams/processor/internals/metrics/ThreadMetrics.java
##########
@@ -91,6 +94,10 @@ private ThreadMetrics() {}
         "The fraction of time the thread spent on polling records from 
consumer";
     private static final String COMMIT_RATIO_DESCRIPTION =
         "The fraction of time the thread spent on committing all tasks";
+    private static final String BLOCKED_TIME_DESCRIPTION =
+        "The total time the thread spent blocked on kafka";

Review comment:
       ` in nanoseconds`?




-- 
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-unsubscr...@kafka.apache.org

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


Reply via email to