apoorvmittal10 commented on code in PR #17021:
URL: https://github.com/apache/kafka/pull/17021#discussion_r1775467769


##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/StreamsClientMetricsDelegatingReporter.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.internals.metrics;
+
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.common.metrics.KafkaMetric;
+import org.apache.kafka.common.metrics.MetricsReporter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+public class StreamsClientMetricsDelegatingReporter implements MetricsReporter 
{
+
+    private static final Logger log = 
LoggerFactory.getLogger(StreamsClientMetricsDelegatingReporter.class);
+    private final Admin adminClient;
+
+    public StreamsClientMetricsDelegatingReporter(final Admin adminClient) {
+        this.adminClient = Objects.requireNonNull(adminClient);
+        log.debug("Creating Client Metrics reporter for admin client {}", 
adminClient);
+    }
+
+    @Override
+    public void init(final List<KafkaMetric> metrics) {
+        metrics.forEach(this::metricChange);
+    }
+
+    @Override
+    public void metricChange(final KafkaMetric metric) {
+        if (isStreamsClientMetric(metric)) {
+            log.debug("Registering metric {}", metric.metricName());
+            adminClient.registerMetricForSubscription(metric);
+        }
+    }
+
+    private boolean isStreamsClientMetric(final KafkaMetric metric) {
+        final boolean shouldInclude = 
metric.metricName().group().equals("stream-metrics");

Review Comment:
   What about `stream-thread-metrics`, `stream-task-metrics`, 
`stream-processor-node-metrics`, `stream-state-metrics` and 
`stream-record-cache-metrics`? Are they not needed or they fall in same 
`stream-metrics` group?



##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/StreamsClientMetricsDelegatingReporter.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.internals.metrics;
+
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.common.metrics.KafkaMetric;
+import org.apache.kafka.common.metrics.MetricsReporter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+public class StreamsClientMetricsDelegatingReporter implements MetricsReporter 
{

Review Comment:
   And are we going to expect this reporter being registered additionally in 
`metrics.reporter` server config to send Streams metrics?



##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/StreamsClientMetricsDelegatingReporter.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.internals.metrics;
+
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.common.metrics.KafkaMetric;
+import org.apache.kafka.common.metrics.MetricsReporter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+public class StreamsClientMetricsDelegatingReporter implements MetricsReporter 
{

Review Comment:
   Ahhh, I see it's added as default metrics reporter on metrics instance.



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