kafka-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Stepanov (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (KAFKA-3923) MetricReporter interface depends on final class KafkaMetric instead of Metric interface
Date Fri, 01 Jul 2016 10:30:11 GMT

     [ https://issues.apache.org/jira/browse/KAFKA-3923?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Igor Stepanov updated KAFKA-3923:
---------------------------------
    Description: 
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?

  was:
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 fulfils most of the needs?


> 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)

Mime
View raw message