Status

Current state: Under Discussion

Discussion thread: here

JIRA: here

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

Kafka currently lacks a straightforward and efficient mechanism for determining whether a given metric is measurable. Existing approaches often rely on:

This small KIP proposes to introduce a new method, isMeasurable(), to the KafkaMetric class, eliminating the need for accessing private fields or handling exceptions in case of non-measurable metrics.

Public Interfaces

	/**
     * The method determines if the metric value provider is of type Measurable.
     *
     * @return true if the metric value provider is of type Measurable, false otherwise.
     */
    public boolean isMeasurable();


Proposed Changes

  1. Add isMeasurable() Method in KafkaMetric.java:

Compatibility, Deprecation, and Migration Plan

Test Plan

Rejected Alternatives

Wrapper Object for exception-based measurability checks

Summary: This approach considered creating a wrapper object around KafkaMetric to mitigate the performance overhead associated with the exception-based measurable method. Similar to Open-Telemetry’s Kafka Client adapter, the wrapper would store the measurability information to avoid repeated exception handling.

Rejected because: While the wrapper concept addresses the issue of exception-based checks, it introduces additional complexity and potential overheads of maintaining the wrapper objects of KafkaMetric itself. The proposed isMeasurable() method provides a more focused and efficient solution for determining metric measurability and reducing unnecessary burden on users with wrapper objects.