]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: stats-service-openmetrics - Check label for group_by metric at correct location.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 22 Apr 2020 10:54:44 +0000 (12:54 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 22 Apr 2020 13:21:36 +0000 (16:21 +0300)
src/stats/stats-service-openmetrics.c

index 0abc8ec7bda0375ffa0c21e961d0e0a908bf2788..6657f7eaaaabcde991c807e1f75b6f7ab8e19783 100644 (file)
@@ -366,21 +366,10 @@ openmetrics_export_sub_metric_get(struct openmetrics_request_sub_metric *reqsm)
 {
        struct metric *const *sub_metric;
 
-       /* Get the first valid sub-metric */
-
        if (reqsm->sub_index >= array_count(&reqsm->metric->sub_metrics))
                return NULL;
 
        sub_metric = array_idx(&reqsm->metric->sub_metrics, reqsm->sub_index);
-       while (((*sub_metric)->group_by == NULL ||
-               !openmetrics_check_name((*sub_metric)->group_by->field)) &&
-              ++reqsm->sub_index < array_count(&reqsm->metric->sub_metrics)) {
-               sub_metric = array_idx(&reqsm->metric->sub_metrics,
-                                      reqsm->sub_index);
-       }
-       if (reqsm->sub_index == array_count(&reqsm->metric->sub_metrics))
-               return NULL;
-
        return *sub_metric;
 }
 
@@ -403,6 +392,7 @@ openmetrics_export_sub_metric_down(struct openmetrics_request *req)
        /* Descend further into sub-metric tree */
 
        if (reqsm->metric->group_by == NULL ||
+           !openmetrics_check_name(reqsm->metric->group_by->field) ||
            !array_is_created(&reqsm->metric->sub_metrics) ||
            array_count(&reqsm->metric->sub_metrics) == 0)
                return NULL;