]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: stats-service-openmetrics - Always clear the stack before next metric body
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 19 May 2022 09:39:55 +0000 (12:39 +0300)
committerMartti Rannanjärvi <martti.rannanjarvi@open-xchange.com>
Mon, 23 May 2022 05:57:16 +0000 (08:57 +0300)
If the attempt of generating output for the previous metric doesn’t completely
consume the stack, the next metric will start with a non-empty stack, which breaks
the metrics output.

src/stats/stats-service-openmetrics.c

index 9c50592e2eb0f2850712b570d676181d73282464..c286c67d53b65b055cf098971fce3660e223a8e7 100644 (file)
@@ -595,6 +595,8 @@ openmetrics_export_continue(struct openmetrics_request *req, string_t *out)
                /* Export the HELP/TYPE header for the current metric */
                str_truncate(req->labels, req->labels_pos);
                req->has_submetric = FALSE;
+               if (array_is_created(&req->sub_metric_stack))
+                       array_clear(&req->sub_metric_stack);
                openmetrics_export_metric_header(req, out);
                req->state = OPENMETRICS_REQUEST_STATE_SUB_METRICS;
                break;