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


##########
clients/src/main/java/org/apache/kafka/common/telemetry/collector/MetricsCollector.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.common.telemetry.collector;
+
+import org.apache.kafka.common.annotation.InterfaceStability;
+import org.apache.kafka.common.telemetry.emitter.Emitter;
+
+/**
+ * A {@code MetricsCollector} is responsible for scraping a source of metrics 
and forwarding
+ * them to the given {@link Emitter}. For example, a given collector might be 
used to collect
+ * system metrics, Kafka metrics, JVM metrics, or other metrics that are to be 
captured, exposed,
+ * and/or forwarded.
+ *
+ * <p/>
+ *
+ * In general, a {@code MetricsCollector} implementation is closely managed by 
another entity
+ * (that entity is colloquially referred to as the "telemetry reporter") that 
will be in
+ * charge of its lifecycle via the {@link #start()} and {@link #stop()} 
methods. The telemetry
+ * reporter should ensure that the {@link #start()} method is invoked <i>once 
and only once</i>
+ * before calls to {@link #collect(Emitter)} are made. Implementations of 
{@code MetricsCollector}
+ * should allow for the corner-case that {@link #stop()} is called before 
{@link #start()},
+ * which might happen in the case of error on startup of the telemetry 
reporter.
+ *
+ * <p/>
+ *
+ * Regarding threading, the {@link #start()} and {@link #stop()} methods may 
be called from
+ * different threads and so proper care should be taken by implementations of 
the
+ * {@code MetricsCollector} interface to be thread-safe. However, the 
telemetry reporter must
+ * ensure that the {@link #collect(Emitter)} method should only be invoked in 
a synchronous
+ * manner.
+ *
+ * @see Emitter
+ */
[email protected]
+public interface MetricsCollector {

Review Comment:
   Yes these are internal interfaces. I have asked a query regarding internal 
packages to @philipnee and @kirktrue in some other comment. I ll place the 
classes accordingly then.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to