kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject kafka git commit: KAFKA-3785; Fetcher spending unnecessary time during metrics recording
Date Fri, 03 Jun 2016 08:41:44 GMT
Repository: kafka
Updated Branches:
  refs/heads/0.10.0 de23c6376 -> c91f742de


KAFKA-3785; Fetcher spending unnecessary time during metrics recording

Author: Greg Fodor <gfodor@gmail.com>

Reviewers: Ismael Juma <ismael@juma.me.uk>

Closes #1464 from gfodor/gfodor/kafka-3785

(cherry picked from commit 7699b91f870f58e71dbdeddba79b58f009f9c0a2)
Signed-off-by: Ismael Juma <ismael@juma.me.uk>


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/c91f742d
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/c91f742d
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/c91f742d

Branch: refs/heads/0.10.0
Commit: c91f742deb8b83d59847f2afb7a786f18b34eb1d
Parents: de23c63
Author: Greg Fodor <gfodor@gmail.com>
Authored: Fri Jun 3 09:41:26 2016 +0100
Committer: Ismael Juma <ismael@juma.me.uk>
Committed: Fri Jun 3 09:41:41 2016 +0100

----------------------------------------------------------------------
 .../apache/kafka/clients/consumer/internals/Fetcher.java    | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/c91f742d/clients/src/main/java/org/apache/kafka/clients/consumer/internals/Fetcher.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/clients/consumer/internals/Fetcher.java
b/clients/src/main/java/org/apache/kafka/clients/consumer/internals/Fetcher.java
index 0256fe7..ddfb584 100644
--- a/clients/src/main/java/org/apache/kafka/clients/consumer/internals/Fetcher.java
+++ b/clients/src/main/java/org/apache/kafka/clients/consumer/internals/Fetcher.java
@@ -770,13 +770,13 @@ public class Fetcher<K, V> {
         }
 
         public void recordTopicFetchMetrics(String topic, int bytes, int records) {
-            Map<String, String> metricTags = new HashMap<>();
-            metricTags.put("topic", topic.replace(".", "_"));
-
             // record bytes fetched
             String name = "topic." + topic + ".bytes-fetched";
             Sensor bytesFetched = this.metrics.getSensor(name);
             if (bytesFetched == null) {
+                Map<String, String> metricTags = new HashMap<>(1);
+                metricTags.put("topic", topic.replace('.', '_'));
+
                 bytesFetched = this.metrics.sensor(name);
                 bytesFetched.add(this.metrics.metricName("fetch-size-avg",
                         this.metricGrpName,
@@ -797,6 +797,9 @@ public class Fetcher<K, V> {
             name = "topic." + topic + ".records-fetched";
             Sensor recordsFetched = this.metrics.getSensor(name);
             if (recordsFetched == null) {
+                Map<String, String> metricTags = new HashMap<>(1);
+                metricTags.put("topic", topic.replace('.', '_'));
+
                 recordsFetched = this.metrics.sensor(name);
                 recordsFetched.add(this.metrics.metricName("records-per-request-avg",
                         this.metricGrpName,


Mime
View raw message