]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
stats: Change metric_fields setting to boollist
authorsergey.kitov <sergey.kitov@open-xchange.com>
Thu, 29 Aug 2024 08:46:38 +0000 (11:46 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:39:59 +0000 (10:39 +0200)
src/stats/client-reader.c
src/stats/stats-metrics.c
src/stats/stats-settings.c
src/stats/stats-settings.h

index 89370c8120e1c1021e1a3997cb82cc553ceeae29..abcedc8bcb81f66b3fc746cac0adeb28aae0be7b 100644 (file)
@@ -8,6 +8,7 @@
 #include "connection.h"
 #include "ostream.h"
 #include "settings.h"
+#include "settings-parser.h"
 #include "master-service.h"
 #include "stats-metrics.h"
 #include "stats-settings.h"
@@ -171,12 +172,21 @@ reader_client_input_metrics_add(struct reader_client *client,
        set->pool = pool;
        set->name = p_strdup(pool, args[0]);
        set->description = p_strdup(pool, args[1]);
-       set->fields = p_strdup(pool, args[2]);
        set->group_by = p_strdup(pool, args[3]);
        set->filter = p_strdup(pool, args[4]);
        set->exporter = p_strdup(pool, args[5]);
        set->exporter_include = p_strdup(pool, args[6]);
 
+       p_array_init(&set->fields, pool, 4);
+       if (settings_parse_boollist_string(args[2], pool, &set->fields,
+                                          &error) < 0) {
+               e_error(client->conn.event,
+                       "METRICS-ADD: Invalid metric_fields: %s", error);
+               pool_unref(&pool);
+               return -1;
+       }
+       settings_boollist_finish(&set->fields, FALSE);
+
        if (!stats_metric_setting_parser_info.check_func(set, pool, &error)) {
                e_error(client->conn.event, "METRICS-ADD: %s", error);
                pool_unref(&pool);
index 046f7982d3ce18c26b4978903a50e3108201aafb..7da3457bb5fe191687bff54a8bd93eb80bd18d9c 100644 (file)
@@ -171,7 +171,7 @@ static int stats_metrics_add_set(struct stats_metrics *metrics,
                }
        }
 
-       fields = t_strsplit_spaces(set->fields, " ");
+       fields = settings_boollist_get(&set->fields);
        metric = stats_metric_alloc(metrics->pool, set->name, set, fields);
 
        if (array_is_created(&set->parsed_group_by))
index e236dc24768c70925e6cc7f3423b12c93678d659..63a9d72457a4666cb812984876786d7651f4426f 100644 (file)
@@ -106,7 +106,7 @@ const struct setting_parser_info stats_exporter_setting_parser_info = {
 
 static const struct setting_define stats_metric_setting_defines[] = {
        DEF(STR, name),
-       DEF(STR, fields),
+       DEF(BOOLLIST, fields),
        DEF(STR_NOVARS, group_by),
        DEF(STR, filter),
        DEF(STR, exporter),
@@ -117,7 +117,7 @@ static const struct setting_define stats_metric_setting_defines[] = {
 
 const struct stats_metric_settings stats_metric_default_settings = {
        .name = "",
-       .fields = "",
+       .fields = ARRAY_INIT,
        .filter = "",
        .exporter = "",
        .group_by = "",
index cb50f9ce8a2a5680b432325a8245d11b712ba6e3..adcaeb8326b88befbef001f74b99df330372a006 100644 (file)
@@ -107,7 +107,7 @@ struct stats_metric_settings {
 
        const char *name;
        const char *description;
-       const char *fields;
+       ARRAY_TYPE(const_string) fields;
        const char *group_by;
        const char *filter;