mimaison commented on code in PR #19050: URL: https://github.com/apache/kafka/pull/19050#discussion_r2041136887
########## 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 + * @param metrics the metrics + * @param name extra tag name to add + * @param value extra tag value to add + * @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, String name, String value) { Review Comment: At the moment all the callers have a single extra tag, so it's simpler than having them build a `LinkedHashMap`. -- 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