Skip to content

Conversation

kirktrue
Copy link
Contributor

@kirktrue kirktrue commented Oct 2, 2025

This change introduces AbstractConsumerMetricsManager as a shared base class for consumer metrics managers, consolidating the steps of registering and cleanup logic.

…Metrics

Introduces AbstractConsumerMetricsManager as a shared base class for consumer metrics managers, consolidating metric and sensor registration and cleanup logic. Updates all relevant metrics manager classes to extend this base, reducing code duplication and improving maintainability.
Changed AbstractConsumerMetricsManager to use Set for sensors and added debug output in close(). Introduced AbstractConsumerMetricsManagerTest as a base test class for metrics cleanup verification. Updated AsyncConsumerMetricsTest and ConsumerRebalanceMetricsManagerTest to extend the new base test and implement required methods.
Moved sensor and metric management logic into AbstractConsumerMetricsManager, replacing SensorBuilder with an inner class. Updated FetchMetricsManager, ShareFetchMetricsManager, and related classes to extend AbstractConsumerMetricsManager and use its utilities. Ensured proper cleanup of metrics and sensors on close, added tests to verify metrics removal, and improved constructor usage with @SuppressWarnings. This change centralizes and simplifies metrics lifecycle management for Kafka consumers.
@github-actions github-actions bot added triage PRs from the community consumer clients labels Oct 2, 2025
Copy link
Contributor

@LiamClarkeNZ LiamClarkeNZ left a comment

Choose a reason for hiding this comment

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

After my first read through, looks like a good way to centralise clean up of metrics :)


assertTrue(consumer.metrics().size() > 1, "The consumer should have created many metrics");
consumer.close(CloseOptions.timeout(Duration.ZERO));
assertTrue(consumer.metrics().size() <= 1, "The consumer should have removed all of its metrics");
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious about the > 1 and <= 1, reads like there's usually a metric just hanging around in there?

@github-actions github-actions bot removed the triage PRs from the community label Oct 5, 2025
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