Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ClassConfigReason
KafkaMetricsReporterkafka.metrics.reportersThis interface is technically not part of the public API. Since MetricsReporter will not support it, it makes sense to not add it to this one either.
ConsumerPartitionAssignorpartition.assignment.strategyThis interface does not have a close() method. This interface is being deprecated by KIP-848, hence I don't propose updating it.
DeserializationExceptionHandlerdefault.deserialization.exception.handlerThis interface does not have a close() method.
ProductionExceptionHandlerdefault.production.exception.handlerThis interface does not have a close() method.
TimestampExtractordefault.timestamp.extractorThis interface does not have a close() method.
RocksDBConfigSetterrocksdb.config.setterThis interface does not have a close() method.
SecurityProviderCreatorsecurity.providersThis interface does not have a close() method. The instance is passed to java.security.Security and we don't control its lifecycle.
ReplicationPolicyreplication.policy.classMirrorMaker currently uses its own mechanism to emit metrics. This interface does not have a close() method.
ConfigPropertyFilterconfig.property.filter.classMirrorMaker currently uses its own mechanism to emit metrics.
GroupFiltergroup.filter.classMirrorMaker currently uses its own mechanism to emit metrics.
TopicFiltertopic.filter.classMirrorMaker currently uses its own mechanism to emit metrics.
ForwardingAdminforwarding.admin.classMirrorMaker currently uses its own mechanism to emit metrics.

...

Code Block
languagejava
public class MyInterceptor<K, V> implements ProducerInterceptor<K, V>, Monitorable {

    private Sensor sensor;
    private PluginMetrics metrics;

    public void withPluginMetrics(PluginMetrics metrics) {
        this.metrics = metrics;
        sensor = metrics.sensor("onSend");
        MetricName rate = metrics.metricName("rate", "Average number of calls per second.", Collections.emptyMap());
        MetricName total = metrics.metricName("total", "Total number of calls.", Collections.emptyMap());
        sensor.add(rate, new Rate());
        sensor.add(total, new CumulativeCount());
    }

    @Override
    public ProducerRecord<K, V> onSend(ProducerRecord<K, V> record) {
        sensor.record();
        return record;
    }

    @Override
    public void close() {
        try {
            if (metrics != null) metrics.close();
        } catch (IOException e) { // Even though ProducerInterceptor extends AutoCloseable which has "void close() throws Exception;", ProducerInterceptor has its own close() method without "throws"!
            throw new RuntimeException(e);
        }
    }
}

...