-
-
Notifications
You must be signed in to change notification settings - Fork 193
Avoid recreating the metrics for each cluster to support global labels #82
Conversation
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 quick turnaround on the PR. I left a few comments.
src/main/scala/com/lightbend/kafkalagexporter/PrometheusEndpointSink.scala
Outdated
Show resolved
Hide resolved
"environment" -> "prod", | ||
"org" -> "organization2", | ||
"location" -> "canada" | ||
) |
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.
It's possible for clusters with no labels defined to report metrics. When you use the Strimzi cluster watcher, clusters are added at runtime and will have an empty set of labels. Can you add/update a test to include a cluster with labels defined, and one with none defined, and assert that it works. I assume the result would be blank label values for the clusters that have none defined.
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.
@seglo Nice catch :) I added those test cases and made some minor changes in the implementation to accommodate this requirement.
src/main/scala/com/lightbend/kafkalagexporter/PrometheusEndpointSink.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/lightbend/kafkalagexporter/PrometheusEndpointSink.scala
Outdated
Show resolved
Hide resolved
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.
Looking good. Thanks for your patience. Just some minor docs updates.
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 for your patience during the review!
seglo#82) * Avoid recreating the metrics for each cluster * Handle global labels for `Strimzi` cluster watcher logic * Refactored as per the comments * Updated docs as per suggestion
This fixes the issue reproduced in 78.
Java prometheus client library does not let us register metrics more than once with different sets of labels. The idea is not to register prometheus metrics for each cluster and to create once with all the labels defined in all the cluster.