]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: openmetrics - Include submetric name only when present
authorJosef 'Jeff' Sipek <jeff.sipek@open-xchange.com>
Mon, 19 Oct 2020 17:47:10 +0000 (13:47 -0400)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 1 Dec 2020 08:46:24 +0000 (08:46 +0000)
Otherwise we SIGSEGV.

src/stats/stats-service-openmetrics.c

index a380b0bc73d328aa631bfd216830a7e282ba0148..6b312eb4ae321ca823fd806bb490f42662e867e9 100644 (file)
@@ -290,9 +290,13 @@ static void
 openmetrics_export_submetric(struct openmetrics_request *req, string_t *out,
                             const struct metric *metric, int64_t timestamp)
 {
-       str_append_c(req->labels, '"');
-       json_append_escaped(req->labels, metric->sub_name);
-       str_append_c(req->labels, '"');
+       /* This metric may be a submetric and therefore have a label
+          associated with it. */
+       if (metric->sub_name != NULL) {
+               str_append_c(req->labels, '"');
+               json_append_escaped(req->labels, metric->sub_name);
+               str_append_c(req->labels, '"');
+       }
 
        if (req->metric_type == OPENMETRICS_METRIC_TYPE_HISTOGRAM) {
                if (metric->group_by == NULL ||