[ https://issues.apache.org/jira/browse/KAFKA-3923?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15359202#comment-15359202 ]
ASF GitHub Bot commented on KAFKA-3923: --------------------------------------- GitHub user stepio opened a pull request: https://github.com/apache/kafka/pull/1579 KAFKA-3923: Use Metric interface instead of final KafkaMetric in MetricsReporter and its implementations This is a patch for the previously highlighted issue: https://issues.apache.org/jira/browse/KAFKA-3923 I'm minimised the scope of changes, so that now Metrics class is not affected and generics are introduced on the method level instead of class level. You can merge this pull request into a Git repository by running: $ git pull https://github.com/stepio/kafka metrics_reporter Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/1579.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1579 ---- commit 06841765707f40d553ab9c7ae635bfc67b7bb05d Author: Igor Stepanov <stepio...@gmail.com> Date: 2016-07-01T16:10:55Z KAFKA-3923: Use Metric interface instead of final KafkaMetric in MetricsReporter and its implementations - simplifies mocking of metrics for unit tests ---- > MetricReporter interface depends on final class KafkaMetric instead of Metric > interface > --------------------------------------------------------------------------------------- > > Key: KAFKA-3923 > URL: https://issues.apache.org/jira/browse/KAFKA-3923 > Project: Kafka > Issue Type: Improvement > Components: clients > Reporter: Igor Stepanov > > Hello, > I'm working on exposing Kafka's consumer/producer metrics to Spring Actuator. > To achieve this, I've implemented Kafka's MetricReporter interface to allow > injecting it into the appropriate consumer/producer. No issues with > implementation itself, fine for me. > But now I've moved to writing unit tests for this implementation and decided > to use mocked KafkaMetric instances for this. But mocking of KafkaMetric > itself is not so plain - the class is final. The logical step is to use > Metric interface for mocking, but MetricReporter accepts only KafkaMetric. > I know that technically I can use PowerMock and most probably it will work > fine in this case, but talking about Kafka itself, is it a good approach to > depend on the exact implementation when interface is available? -- This message was sent by Atlassian JIRA (v6.3.4#6332)