m1a2st commented on code in PR #19050:
URL: https://github.com/apache/kafka/pull/19050#discussion_r2041132013


##########
clients/src/main/java/org/apache/kafka/common/internals/Plugin.java:
##########
@@ -40,14 +47,46 @@ private Plugin(T instance, PluginMetricsImpl pluginMetrics) 
{
         this.pluginMetrics = Optional.ofNullable(pluginMetrics);
     }
 
+    /**
+     * Wrap an instance into a Plugin.
+     * @param instance the instance to wrap
+     * @param metrics the metrics
+     * @param tagsSupplier supplier to retrieve the tags
+     * @return the plugin
+     */
+    public static <T> Plugin<T> wrapInstance(T instance, Metrics metrics, 
Supplier<Map<String, String>> tagsSupplier) {
+        PluginMetricsImpl pluginMetrics = null;
+        if (instance instanceof Monitorable && metrics != null) {
+            pluginMetrics = new PluginMetricsImpl(metrics, tagsSupplier.get());
+            ((Monitorable) instance).withPluginMetrics(pluginMetrics);
+        }
+        return new Plugin<>(instance, pluginMetrics);
+    }
+
+    /**
+     * Wrap an instance into a Plugin.
+     * @param instance the instance to wrap
+     * @param metrics the metrics
+     * @param key the value for the <code>config</code> tag
+     * @return the plugin
+     */
     public static <T> Plugin<T> wrapInstance(T instance, Metrics metrics, 
String key) {
         return wrapInstance(instance, metrics, () -> tags(key, instance));
     }
 
-    public static <T> Plugin<T> wrapInstance(T instance, Metrics metrics, 
String key, Map<String, String> extraTags) {
+    /**
+     * Wrap an instance into a Plugin.
+     * @param instance the instance to wrap

Review Comment:
   I think we should also mention that the instance's class name will be used 
as the value for the `<code>class</code>` tag.



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