-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move label filtering into KafkaPrometheusReporter and out of the KafkaPrometheusCollector #38
Move label filtering into KafkaPrometheusReporter and out of the KafkaPrometheusCollector #38
Conversation
Signed-off-by: Owen <[email protected]>
f3ab94a
to
bf86d91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, I left a few comments.
src/main/java/io/strimzi/kafka/metrics/KafkaMetricsCollector.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporter.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporter.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporter.java
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaMetricsCollectorTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaMetricsCollectorTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaMetricsCollectorTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporterTest.java
Show resolved
Hide resolved
Signed-off-by: Owen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates! I looks good overall. I left a few more suggestions but we're almost there.
src/main/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporter.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaMetricsCollectorTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaMetricsCollectorTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaMetricsCollectorTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporterTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporterTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/strimzi/kafka/metrics/KafkaPrometheusMetricsReporterTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Owen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made another pass and left a few more minor suggestions
Measurable measurable = (config, now) -> value; | ||
return new KafkaMetric( | ||
KafkaMetric metric = new KafkaMetric( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the same naming as in newNonNumericMetric()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Changed to kafkaMetric
new Object(), | ||
new MetricName(name, group, "", tagsMap), | ||
new MetricName(metricName.name(), metricName.group(), "", tagsMap), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use metricName
here like in newNonNumericMetric()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I missed that. Now using metricName
collector.addMetric(buildMetric("name", "other", 2.0)); | ||
metrics = collector.collect(); | ||
assertEquals(0, metrics.size()); | ||
// Add a metric |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should we keep gerunds so all comments are similar?
Same in the other comment you updated below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to Adding
etc.
reporter.close(); | ||
} | ||
|
||
@Test | ||
public void testMultipleReporters() throws Exception { | ||
Map<String, String> configs = new HashMap<>(); | ||
configs.put(PrometheusMetricsReporterConfig.LISTENER_CONFIG, "http://:0"); | ||
configs.put(PrometheusMetricsReporterConfig.ALLOWLIST_CONFIG, "kafka_server_group_name.*"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to set this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed here. Removed
public void metricChange(KafkaMetric metric) { | ||
kafkaMetricsCollector.addMetric(metric); | ||
String prometheusName = MetricWrapper.prometheusName(this.prefix, metric.metricName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.prefix
-> prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Signed-off-by: Owen <[email protected]>
@mimaison Thanks for the extra pass and comments. Hopefully there's nothing missed now. |
private final PrometheusRegistry registry; | ||
@SuppressFBWarnings({"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"}) // This field is initialized in the configure method | ||
private KafkaMetricsCollector kafkaMetricsCollector; | ||
private KafkaMetricsCollector collector; | ||
@SuppressFBWarnings({"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"}) // This field is initialized in the init method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init
-> configure
@SuppressFBWarnings({"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"}) // This field is initialized in the configure method | ||
private Optional<HTTPServer> httpServer; | ||
@SuppressFBWarnings({"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"}) // This field is initialized in the setPrefix method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setPrefix
-> contextChange
Signed-off-by: Owen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR is in response to the following issue: #9
Moving the label filtering into the
metricChange
method means that filtering is done when the Reporter is initialised. It was previously done in thecollect
method.