rodesai commented on a change in pull request #11149: URL: https://github.com/apache/kafka/pull/11149#discussion_r688244445
########## File path: streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamsThreadTotalBlockedTime.java ########## @@ -0,0 +1,61 @@ +/* + * 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.streams.processor.internals; + +import java.util.Map; +import java.util.function.Supplier; +import org.apache.kafka.clients.consumer.Consumer; +import org.apache.kafka.common.Metric; +import org.apache.kafka.common.MetricName; + +public class StreamsThreadTotalBlockedTime { + final Consumer<?, ?> consumer; + final Consumer<?, ?> restoreConsumer; + final Supplier<Double> producerTotalBlockedTime; + + StreamsThreadTotalBlockedTime( + final Consumer<?, ?> consumer, + final Consumer<?, ?> restoreConsumer, + final Supplier<Double> producerTotalBlockedTime + ) { + this.consumer = consumer; + this.restoreConsumer = restoreConsumer; + this.producerTotalBlockedTime = producerTotalBlockedTime; + } + + final double getMetricValue( Review comment: I tried doing it this way at first, but found it hard to loop over the producers in `TaskManager/Tasks/ActiveTaskCreator` without breaking those abstractions by adding methods to return the producers so we could get the metrics out. So then I went the route of having the total blocked time metric implementation ask `TaskManager` for it's total blocked time component. > we can also use this in unit test e.g. https://github.com/apache/kafka/pull/11149/files#diff-599de0f96fbd5ba6b3d919881426269fc72fe8bbe8e2436fab87d9abe84e8dbaR735 What do you mean here? This is the producer's unit test, and this method is computing total blocked time for a streams app. -- 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