cadonna commented on a change in pull request #9696:
URL: https://github.com/apache/kafka/pull/9696#discussion_r538129015



##########
File path: 
streams/src/main/java/org/apache/kafka/streams/processor/internals/metrics/StreamsMetricsImpl.java
##########
@@ -235,11 +235,12 @@ public final Sensor threadLevelSensor(final String 
threadId,
         final String key = threadSensorPrefix(threadId);
         synchronized (threadLevelSensors) {
             final String fullSensorName = key + SENSOR_NAME_DELIMITER + 
sensorName;
-            return Optional.ofNullable(metrics.getSensor(fullSensorName))
-                .orElseGet(() -> {
-                    threadLevelSensors.computeIfAbsent(key, ignored -> new 
LinkedList<>()).push(fullSensorName);
-                    return metrics.sensor(fullSensorName, recordingLevel, 
parents);
-                });
+            final Sensor sensor = metrics.getSensor(fullSensorName);
+            if (sensor == null) {
+                threadLevelSensors.computeIfAbsent(key, ignored -> new 
LinkedList<>()).push(fullSensorName);

Review comment:
       The number of elements is not always 1. Each created thread-level sensor 
is added to this queue, e.g., `processLatencySensor`, `pollRecordsSensor`, etc. 
Check out the callers of `threadLevelSensor()`.




----------------------------------------------------------------
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.

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


Reply via email to