]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Do not break submetrics is field is missing
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 6 Jul 2023 07:49:48 +0000 (10:49 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 11 Jul 2023 10:46:43 +0000 (10:46 +0000)
If the field does not exist, emulate it as empty field, and continue
submetrics.

src/stats/stats-metrics.c

index 301a0e5fc4a8b429ecf9df5209fc821dc5acb462..96dca8be2b30607730f093447c918eae1c299e08 100644 (file)
@@ -642,10 +642,17 @@ stats_metric_group_by(struct metric *metric, struct event *event, pool_t pool)
                event_find_field_recursive(event, metric->group_by[0].field);
 
        /* ignore missing field */
-       if (field == NULL)
-               return;
-
-       if (field->value_type != EVENT_FIELD_VALUE_TYPE_STRLIST)
+       if (field == NULL) {
+               const struct event_field empty_event_field = {
+                       .value_type = EVENT_FIELD_VALUE_TYPE_STR,
+                       .key = metric->group_by[0].field,
+                       .value = {
+                               .str = "",
+                       },
+               };
+               stats_metric_group_by_field(metric, event, &empty_event_field,
+                                           pool);
+       } else if (field->value_type != EVENT_FIELD_VALUE_TYPE_STRLIST)
                stats_metric_group_by_field(metric, event, field, pool);
        else {
                /* Handle each string in strlist separately. The strlist needs