kafka
kafka copied to clipboard
KAFKA-19542: Consumer.close() does not remove all added sensors from Metrics
The intention of the Consumer API is that after close(), metrics()
should return an empty map of metrics. The lifecycle management of the
various metrics managers in the consumer is inconsistent. Some managers
remove all the metrics that were created, some registries remove some of
them, and some don't make any effort to remove the metrics at all.
This change introduces AbstractConsumerMetricsManager as a shared base
class for consumer metrics managers, consolidating the steps of metric
registration and cleanup logic, as well as unit tests to ensure that the
different metrics managers perform the cleanup step.