diff --git a/pom.xml b/pom.xml index 95210ad..46aed72 100644 --- a/pom.xml +++ b/pom.xml @@ -291,7 +291,7 @@ public true - false + true diff --git a/src/main/java/io/strimzi/kafka/metrics/KafkaMetricsCollector.java b/src/main/java/io/strimzi/kafka/metrics/KafkaMetricsCollector.java index b8cfa51..ca5c845 100644 --- a/src/main/java/io/strimzi/kafka/metrics/KafkaMetricsCollector.java +++ b/src/main/java/io/strimzi/kafka/metrics/KafkaMetricsCollector.java @@ -31,11 +31,21 @@ public class KafkaMetricsCollector extends Collector { @SuppressFBWarnings({"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"}) // Should be investigated as part of https://github.com/strimzi/metrics-reporter/issues/12 private String prefix; + /** + * Constructs a new KafkaMetricsCollector with provided configuration. + * + * @param config The configuration for the PrometheusMetricsReporter. + */ public KafkaMetricsCollector(PrometheusMetricsReporterConfig config) { this.config = config; this.metrics = new ConcurrentHashMap<>(); } + /** + * Sets the prefix to be used for metric names. + * + * @param prefix The prefix to set. + */ public void setPrefix(String prefix) { this.prefix = prefix; } @@ -65,10 +75,20 @@ public List collect() { return samples; } + /** + * Adds a Kafka metric to be collected. + * + * @param metric The Kafka metric to add. + */ public void addMetric(KafkaMetric metric) { metrics.put(metric.metricName(), metric); } + /** + * Removes a Kafka metric from collection. + * + * @param metric The Kafka metric to remove. + */ public void removeMetric(KafkaMetric metric) { metrics.remove(metric.metricName()); } diff --git a/src/main/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporter.java b/src/main/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporter.java index 2863f71..28939b4 100644 --- a/src/main/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporter.java +++ b/src/main/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporter.java @@ -89,6 +89,12 @@ public void contextChange(MetricsContext metricsContext) { kafkaMetricsCollector.setPrefix(prefix); } + /** + * + Retrieves the port number on which the HTTP server is running. + * + @return The port number of the HTTP server. + */ public int getPort() { return httpServer.get().getPort(); } diff --git a/src/main/java/io/strimzi/kafka/metrics/MetricFamilySamplesBuilder.java b/src/main/java/io/strimzi/kafka/metrics/MetricFamilySamplesBuilder.java index abf0754..621be19 100644 --- a/src/main/java/io/strimzi/kafka/metrics/MetricFamilySamplesBuilder.java +++ b/src/main/java/io/strimzi/kafka/metrics/MetricFamilySamplesBuilder.java @@ -22,6 +22,12 @@ public class MetricFamilySamplesBuilder { private final String help; private final List samples; + /** + * Constructor for MetricFamilySamplesBuilder. + * + * @param type The type of the metric family. + * @param help The help string for the metric family. + */ public MetricFamilySamplesBuilder(Collector.Type type, String help) { this.type = type; this.help = help; diff --git a/src/main/java/io/strimzi/kafka/metrics/YammerMetricsCollector.java b/src/main/java/io/strimzi/kafka/metrics/YammerMetricsCollector.java index fd573ad..fc33c75 100644 --- a/src/main/java/io/strimzi/kafka/metrics/YammerMetricsCollector.java +++ b/src/main/java/io/strimzi/kafka/metrics/YammerMetricsCollector.java @@ -38,6 +38,11 @@ public class YammerMetricsCollector extends Collector { private final List registries; private final PrometheusMetricsReporterConfig config; + /** + * Constructs a new YammerMetricsCollector with the provided configuration. + * + * @param config The configuration for the YammerMetricsCollector. + */ public YammerMetricsCollector(PrometheusMetricsReporterConfig config) { this.config = config; this.registries = Arrays.asList(KafkaYammerMetrics.defaultRegistry(), Metrics.defaultRegistry());