szaszm commented on code in PR #1340:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1340#discussion_r905309695


##########
libminifi/include/core/state/nodes/RepositoryMetrics.h:
##########
@@ -90,15 +87,18 @@ class RepositoryMetrics : public ResponseNode {
     return serialized;
   }
 
+  std::vector<PublishedMetric> calculateMetrics() override {
+    std::vector<PublishedMetric> metrics;
+    for (const auto& [_, repo] : repositories_) {
+      metrics.push_back({"is_running", (repo->isRunning() ? 1.0 : 0.0), 
{{"metric_class", getName()}, {"repository_name", repo->getName()}}});
+      metrics.push_back({"is_full", (repo->isFull() ? 1.0 : 0.0), 
{{"metric_class", getName()}, {"repository_name", repo->getName()}}});
+      metrics.push_back({"repository_size", 
static_cast<double>(repo->getRepoSize()), {{"metric_class", getName()}, 
{"repository_name", repo->getName()}}});
+    }
+    return metrics;
+  }

Review Comment:
   Now each metric class needs to have two different member functions 
(serialize and calculateMetrics) that perform essentially the same task: 
collect metrics and format them in a specific way. I would prefer to separate 
the "collect metrics" part from the formatting, and have 1 "collect metrics" 
function here, and one formatting function in each of C2Client and somewhere in 
the prometheus extension. I didn't think about the details yet, only have this 
high level idea.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to