Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-3923

MetricReporter interface depends on final class KafkaMetric instead of Metric interface

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • clients
    • None

    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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            stepio.ua Igor Stepanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: