szaszm commented on code in PR #1340:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1340#discussion_r906190403
##########
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:
> Also moving the serialization and the metrics calculation to C2Client and
the metrics publisher would require us to define parts of a newly introduced
metric in 3 places, which would not be really intuitive.
I was thinking about metric-independent formatting in C2Client and the
prometheus extension, so new metrics require only 1 code change, not 2 or 3.
I've added this to a followup refactoring Jira issue:
https://issues.apache.org/jira/browse/MINIFICPP-1869
--
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]