Status

Current state: Under Discussion

Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]

JIRA:

Motivation

All Kafka component register AppInfo  metrics to track the application start time or commit-id etc. These metrics are useful for monitoring and debugging. However, the AppInfo doesn't provide client-id, which is an important information for custom metrics reporter. 

As the AppInfoParser  class registers a JMX MBean with the provided client-id but when it adds metrics to the Metrics registry the client-id is not included.

Public Interfaces

Proposed Changes

1) Update the AppInfoMBean interface to include a new method getClientId().

public interface AppInfoMBean {
    String getVersion();
    String getCommitId();
    Long getStartTimeMs();
    String getClientId();
}

2) Deprecated the old AppInfoMBean implementation and marked it as @Deprecated.

@Deprecated(since = "4.2")
public static class DeprecatedAppInfo implements AppInfoMBean {
} 

3) Introduced a new implementation of AppInfoMBean.

public static class AppInfo implements AppInfoMBean {

    private final Long startTimeMs;

    public AppInfo(long startTimeMs) {
        this.startTimeMs = startTimeMs;
        log.info("Kafka version: {}", AppInfoParser.getVersion());
        log.info("Kafka commitId: {}", AppInfoParser.getCommitId());
        log.info("Kafka startTimeMs: {}", startTimeMs);
        log.info("Kafka client id: {}", AppInfoParser.getClientId());
    }

	// skip...

    @Override
    public String getClientId() {
        return AppInfoParser.getClientId();
    }
}

4) When AppInfoParser registers an MBean, it will register both the new and the deprecated implementations.

public static synchronized void registerAppInfo(String prefix, String id, Metrics metrics, long nowMs) {
    try {
        // skip...
        DeprecatedAppInfo deprecatedMBean = new DeprecatedAppInfo(nowMs);
        AppInfo mBean = new AppInfo(nowMs);
        server.registerMBean(deprecatedMBean, name);
        server.registerMBean(mBean, name);

        registerMetrics(metrics, mBean); // prefix will be added later by JmxReporter
    } catch (JMException e) {
        log.warn("Error registering AppInfo mbean", e);
    }
}

Compatibility, Deprecation, and Migration Plan

For users currently relying on the AppInfoMBean without client-id, it will remain available until Kafka 5.0. New users are encouraged to use the new AppInfoMBean, which includes the client-id tag. This deprecation will be documented in upgrade.html.

In Kafka 5.0, the deprecated AppInfoMBean will be removed.

Test Plan

change unit test or Integration test to verify the new method.

Rejected Alternatives

A new deprecated configuration could be introduced to control the registration of this MBean.

Nevertheless, this approach is considered unnecessary, as it would introduce complexity without significant benefit.