strimzi / metrics-reporter

Prometheus Metrics Reporter for Apache Kafka server and client components
Apache License 2.0
5 stars 9 forks source link

Address Spotbugs errors #12

Closed scholzj closed 3 months ago

scholzj commented 9 months ago

When running Spotbugs against the project, it throws the following errors:

[ERROR] Low: KafkaMetricsCollector.prefix not initialized in constructor and dereferenced in io.strimzi.kafka.metrics.KafkaMetricsCollector.metricName(MetricName) [io.strimzi.kafka.metrics.KafkaMetricsCollector] At KafkaMetricsCollector.java:[line 76] UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR
[ERROR] Low: KafkaPrometheusMetricsReporter.httpServer not initialized in constructor and dereferenced in io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter.getPort() [io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter] At KafkaPrometheusMetricsReporter.java:[line 90] UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR
[ERROR] Low: KafkaPrometheusMetricsReporter.kafkaMetricsCollector not initialized in constructor and dereferenced in io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter.contextChange(MetricsContext) [io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter] At KafkaPrometheusMetricsReporter.java:[line 86] UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR
[ERROR] Low: KafkaPrometheusMetricsReporter.kafkaMetricsCollector not initialized in constructor and dereferenced in io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter.metricChange(KafkaMetric) [io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter] At KafkaPrometheusMetricsReporter.java:[line 55] UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR
[ERROR] Low: KafkaPrometheusMetricsReporter.kafkaMetricsCollector not initialized in constructor and dereferenced in io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter.metricRemoval(KafkaMetric) [io.strimzi.kafka.metrics.KafkaPrometheusMetricsReporter] At KafkaPrometheusMetricsReporter.java:[line 61] UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR

We should try to address them either by fixing them - or if we think they are not an issue we should suppress them.

scholzj commented 9 months ago

As part of #15, I had to suppress the warnings. But they should still be investigated if the suppression is correct or not.

mimaison commented 3 months ago

Fixed in https://github.com/strimzi/metrics-reporter/pull/31