clolov commented on code in PR #12836: URL: https://github.com/apache/kafka/pull/12836#discussion_r1018025744
########## streams/src/main/java/org/apache/kafka/streams/processor/internals/RecordCollectorImpl.java: ########## @@ -219,26 +219,20 @@ public <K, V> void send(final String topic, } if (!topic.endsWith("-changelog")) { - final Map<String, Sensor> producedSensorByTopic = sinkNodeToProducedSensorByTopic.get(processorNodeId); - if (producedSensorByTopic == null) { - log.error("Unable to records bytes produced to topic {} by sink node {} as the node is not recognized.\n" - + "Known sink nodes are {}.", topic, processorNodeId, sinkNodeToProducedSensorByTopic.keySet()); - } else { - // we may not have created a sensor during initialization if the node uses dynamic topic routing, - // as all topics are not known up front, so create the sensor for that topic if absent - final Sensor topicProducedSensor = producedSensorByTopic.computeIfAbsent( + // we may not have created a sensor during initialization if the node uses dynamic topic routing, + // as all topics are not known up front, so create the sensor for this topic if absent + final Sensor topicProducedSensor = producedSensorByTopic.computeIfAbsent( + topic, + t -> TopicMetrics.producedSensor( + Thread.currentThread().getName(), + taskId.toString(), + processorNodeId, topic, - t -> TopicMetrics.producedSensor( - Thread.currentThread().getName(), - taskId.toString(), - processorNodeId, - topic, - context.metrics() - ) - ); - final long bytesProduced = producerRecordSizeInBytes(serializedRecord); - topicProducedSensor.record(bytesProduced, context.currentSystemTimeMs()); - } + context.metrics() + ) + ); + final long bytesProduced = producerRecordSizeInBytes(serializedRecord); + topicProducedSensor.record(bytesProduced, context.currentSystemTimeMs()); Review Comment: A few unit tests fail because this change removes the if-else statement and the passed context is null. What I find more interesting, however, is that the tests do not fail on line 231 following the same reasoning 🤔 -- 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