Skip to content

Conversation

@DDShantanuBadmanji
Copy link

@DDShantanuBadmanji DDShantanuBadmanji commented Oct 1, 2025

Delete this text and replace it with a detailed description of your change. The
PR title and body will become the squashed commit message.

If you would like to tag individuals, add some commentary, upload images, or
include other supplemental information that should not be part of the eventual
commit message, please use a separate comment.

If applicable, please include a summary of the testing strategy (including
rationale) for the proposed change. Unit and/or integration tests are expected
for any behavior change and system tests should be considered for larger
changes.

Summary by CodeRabbit

  • New Features
    • Exposes metrics for configuration providers when they implement Monitorable, with standard tags (config, class, provider).
  • Refactor
    • Unified handling of configuration providers as plugins across clients, MirrorMaker, and Connect. No change to configuration resolution behavior.
  • Documentation
    • Clarified guidance for ConfigProvider on implementing Monitorable and emitted metric tags.
  • Tests
    • Added tests validating monitorable provider metrics and plugin-based wiring.
  • Chores
    • Minor Vagrantfile formatting/comment update.

@coderabbitai
Copy link

coderabbitai bot commented Oct 1, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Replaces direct ConfigProvider usage with Plugin-wrapped providers across clients and Connect. Updates constructors, fields, and wiring to pass Map<String, Plugin>. Adjusts provider instantiation to wrap with Plugin (including metrics/tagging), updates transform and cleanup flows accordingly, and adds tests for monitorable providers and metrics.

Changes

Cohort / File(s) Summary
Dev tooling
Vagrantfile
Formatting-only: blank line and comment header; no behavior changes.
Clients config core
clients/src/main/java/org/apache/kafka/common/config/AbstractConfig.java, clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java, clients/src/main/java/org/apache/kafka/common/config/provider/ConfigProvider.java
Switch handling from ConfigProvider instances to Plugin: instantiation, storage, transformation, and close. ConfigTransformer constructor/field types updated. ConfigProvider Javadoc adds Monitorable/metrics notes.
Connect runtime core
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java, connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfigTransformer.java, connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/Plugins.java, connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMakerConfig.java
Propagate Plugin usage: constructor/type changes, provider map now holds plugins, transformer initialization updated, and close paths updated. Plugins.newConfigProvider now returns Plugin, accepts providerName and Metrics, wraps provider with Plugin including metric tags. MirrorMakerConfig adjusted similarly.
Clients tests
clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java, clients/src/test/java/org/apache/kafka/common/config/provider/MonitorableConfigProvider.java
Tests updated to wrap providers via Plugin.wrapInstance and use Map.of. Add MonitorableConfigProvider test class implementing ConfigProvider+Monitorable with basic metrics wiring.
Connect runtime tests
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConfigTransformerTest.java, connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java, connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginsTest.java
Tests updated for plugin-wrapped providers and new APIs (Metrics param). Add tests validating monitorable providers and PluginMetrics integration; introduce helper assertions for metric tags; adjust access via plugin.get().

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Worker
  participant Plugins
  participant Plugin as Plugin<ConfigProvider>
  participant Provider as ConfigProvider
  participant WCT as WorkerConfigTransformer
  participant CT as ConfigTransformer

  User->>Worker: start / init
  Worker->>Plugins: newConfigProvider(config, providerName, classLoaderUsage, metrics)
  Plugins->>Plugins: instantiate provider (versioned)
  Plugins->>Plugin: wrapInstance(provider, metrics, "config.providers", {"provider": providerName})
  Plugins-->>Worker: Plugin<ConfigProvider>

  Worker->>WCT: new WorkerConfigTransformer(worker, Map{name->Plugin})
  WCT->>CT: new ConfigTransformer(Map{name->Plugin})

  User->>WCT: transform(props)
  WCT->>CT: transform(propsWithVariables)
  CT->>Plugin: get()
  Plugin-->>CT: ConfigProvider
  CT->>Provider: get(path, keys)
  Provider-->>CT: ConfigData(values, ttl)
  CT-->>WCT: resolved props, ttls
  WCT-->>User: resolved props

  Note over Worker,Plugin: Shutdown / cleanup
  Worker->>WCT: close()
  WCT->>Plugin: close()
  Plugin-->>WCT: closed
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

I nibble through configs, hop to and fro,
Wrapping providers in plugins—on we go!
With tidy tags and metrics bright,
I trace each path by moonlit byte.
When ttls fade and tests all pass—
Thump-thump! I stamp approval in the grass. 🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch clone-KAFKA-18894

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed79212 and 5989a26.

📒 Files selected for processing (13)
  • Vagrantfile (1 hunks)
  • clients/src/main/java/org/apache/kafka/common/config/AbstractConfig.java (4 hunks)
  • clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java (3 hunks)
  • clients/src/main/java/org/apache/kafka/common/config/provider/ConfigProvider.java (1 hunks)
  • clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java (5 hunks)
  • clients/src/test/java/org/apache/kafka/common/config/provider/MonitorableConfigProvider.java (1 hunks)
  • connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorMakerConfig.java (2 hunks)
  • connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Worker.java (1 hunks)
  • connect/runtime/src/main/java/org/apache/kafka/connect/runtime/WorkerConfigTransformer.java (3 hunks)
  • connect/runtime/src/main/java/org/apache/kafka/connect/runtime/isolation/Plugins.java (3 hunks)
  • connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerConfigTransformerTest.java (5 hunks)
  • connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java (5 hunks)
  • connect/runtime/src/test/java/org/apache/kafka/connect/runtime/isolation/PluginsTest.java (4 hunks)

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.39.5)
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTest.java

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @DDShantanuBadmanji, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant refactoring to how ConfigProvider instances are managed within Kafka and Kafka Connect. By wrapping ConfigProviders in a generic Plugin object, the system gains a standardized mechanism for lifecycle management, particularly enabling ConfigProvider implementations to register metrics through the Monitorable interface. This change enhances the observability and extensibility of configuration providers, with corresponding updates across various core and Connect runtime components to adopt this new abstraction.

Highlights

  • ConfigProvider Metric Integration: ConfigProvider implementations can now register metrics by implementing the Monitorable interface, with automatic tagging for config, class, and provider.
  • Plugin Wrapper for ConfigProviders: ConfigProvider instances are now consistently wrapped in a Plugin<ConfigProvider> object, standardizing their lifecycle management and integration with Kafka's metrics system.
  • Refactoring of Config Handling: Core components like AbstractConfig, ConfigTransformer, MirrorMakerConfig, Worker, and WorkerConfigTransformer have been updated to utilize the new Plugin<ConfigProvider> type, ensuring consistent handling across the system.
  • Enhanced Test Coverage: New test cases and a MonitorableConfigProvider utility class have been added to thoroughly verify the metric registration functionality and the correct wrapping of ConfigProviders.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the instantiation and handling of ConfigProviders by wrapping them in a Plugin class. This is a significant but well-executed change that enables metrics for ConfigProvider implementations that implement the Monitorable interface. The changes are applied consistently across clients and connect-runtime modules, and the tests have been updated accordingly, including new tests for the metrics functionality.

I've identified one issue in AbstractConfig where the provider metric tag is not being added, which is inconsistent with the new documentation and could affect monitoring. I've provided a suggestion to address this. Overall, the refactoring is a good improvement for the codebase.

ConfigProvider provider = Utils.newInstance(entry.getValue(), ConfigProvider.class);
provider.configure(configProperties);
configProviderInstances.put(entry.getKey(), provider);
Plugin<ConfigProvider> providerPlugin = Plugin.wrapInstance(provider, null, CONFIG_PROVIDERS_CONFIG);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The provider metric tag is missing when wrapping the ConfigProvider instance. The updated Javadoc for ConfigProvider states that the provider tag will be added to the metrics. To ensure consistency with how ConfigProvider plugins are created in connect-runtime and to fulfill the documentation, the provider name (entry.getKey()) should be added as a tag.

Suggested change
Plugin<ConfigProvider> providerPlugin = Plugin.wrapInstance(provider, null, CONFIG_PROVIDERS_CONFIG);
Plugin<ConfigProvider> providerPlugin = Plugin.wrapInstance(provider, null, CONFIG_PROVIDERS_CONFIG, Map.of("provider", entry.getKey()));

@refacto-visz
Copy link

refacto-visz bot commented Oct 1, 2025

⚠️ No Active Seat

The user @DDShantanuBadmanji does not have an active seat allocated for code reviews.

Please contact your organization admin to assign a seat or upgrade your subscription.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants