From: Josef 'Jeff' Sipek Date: Tue, 21 Apr 2020 17:26:06 +0000 (-0400) Subject: stats: Rename 'name' to 'metric_name' in metric { } blocks X-Git-Tag: 2.3.11.2~140 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3fc4ff44a44348ad5d227269e65b2cefaec16554;p=thirdparty%2Fdovecot%2Fcore.git stats: Rename 'name' to 'metric_name' in metric { } blocks There was a decent amount of confusion about what what the 'name' setting meant. In short, metric foo { ... } was equivalent to: metric { name = foo ... } Unfortunately, this was often misunderstood as "the name of the *event* we are interested in". To avoid this confusion, we rename the setting to 'metric_name'. So, from now on, if you want to specify the name inside the metric block (instead of before the '{'), you must use: metric { metric_name = fo ... } --- diff --git a/src/stats/stats-metrics.c b/src/stats/stats-metrics.c index d996837924..55a44a50e8 100644 --- a/src/stats/stats-metrics.c +++ b/src/stats/stats-metrics.c @@ -138,7 +138,7 @@ static void stats_metrics_add_set(struct stats_metrics *metrics, const char *const *tmp; fields = t_strsplit_spaces(set->fields, " "); - metric = stats_metric_alloc(metrics->pool, set->name, set, fields); + metric = stats_metric_alloc(metrics->pool, set->metric_name, set, fields); if (array_is_created(&set->parsed_group_by)) metric->group_by = array_get(&set->parsed_group_by, @@ -167,7 +167,7 @@ static void stats_metrics_add_set(struct stats_metrics *metrics, if (metric->export_info.exporter == NULL) i_panic("Could not find exporter (%s) for metric (%s)", - set->exporter, set->name); + set->exporter, set->metric_name); /* Defaults */ metric->export_info.include = EVENT_EXPORTER_INCL_NONE; diff --git a/src/stats/stats-settings.c b/src/stats/stats-settings.c index ed42078720..6451fb4569 100644 --- a/src/stats/stats-settings.c +++ b/src/stats/stats-settings.c @@ -101,7 +101,7 @@ const struct setting_parser_info stats_exporter_setting_parser_info = { { type, #name, offsetof(struct stats_metric_settings, name), NULL } static const struct setting_define stats_metric_setting_defines[] = { - DEF(SET_STR, name), + DEF(SET_STR, metric_name), DEF(SET_STR, event_name), DEF(SET_STR, source_location), DEF(SET_STR, categories), @@ -115,7 +115,7 @@ static const struct setting_define stats_metric_setting_defines[] = { }; static const struct stats_metric_settings stats_metric_default_settings = { - .name = "", + .metric_name = "", .event_name = "", .source_location = "", .categories = "", @@ -130,7 +130,7 @@ const struct setting_parser_info stats_metric_setting_parser_info = { .defines = stats_metric_setting_defines, .defaults = &stats_metric_default_settings, - .type_offset = offsetof(struct stats_metric_settings, name), + .type_offset = offsetof(struct stats_metric_settings, metric_name), .struct_size = sizeof(struct stats_metric_settings), .parent_offset = (size_t)-1, @@ -481,7 +481,7 @@ static bool stats_metric_settings_check(void *_set, pool_t pool, const char **er struct stats_metric_settings *set = _set; const char *p; - if (set->name[0] == '\0') { + if (set->metric_name[0] == '\0') { *error_r = "Metric name can't be empty"; return FALSE; } @@ -530,7 +530,7 @@ static bool stats_settings_check(void *_set, pool_t pool ATTR_UNUSED, if (!found) { *error_r = t_strdup_printf("metric %s refers to " "non-existent exporter '%s'", - (*metric)->name, + (*metric)->metric_name, (*metric)->exporter); return FALSE; } diff --git a/src/stats/stats-settings.h b/src/stats/stats-settings.h index 7346d360ea..db1b72c576 100644 --- a/src/stats/stats-settings.h +++ b/src/stats/stats-settings.h @@ -95,7 +95,7 @@ struct stats_metric_settings_group_by { /* */ struct stats_metric_settings { - const char *name; + const char *metric_name; const char *description; const char *event_name; const char *source_location; diff --git a/src/stats/test-client-reader.c b/src/stats/test-client-reader.c index 710e9901b2..9ad4016b62 100644 --- a/src/stats/test-client-reader.c +++ b/src/stats/test-client-reader.c @@ -46,7 +46,7 @@ bool test_stats_callback(struct event *event, static const char *settings_blob_1 = "metric=test\n" -"metric/test/name=test\n" +"metric/test/metric_name=test\n" "metric/test/event_name=test\n" "\n"; @@ -125,7 +125,7 @@ static void test_client_reader(void) static const char *settings_blob_2 = "metric=test\n" -"metric/test/name=test\n" +"metric/test/metric_name=test\n" "metric/test/event_name=test\n" "metric/test/group_by=test_name\n" "\n"; diff --git a/src/stats/test-client-writer.c b/src/stats/test-client-writer.c index c7f590996e..265a06aab8 100644 --- a/src/stats/test-client-writer.c +++ b/src/stats/test-client-writer.c @@ -99,7 +99,7 @@ bool test_stats_callback(struct event *event, static const char *settings_blob_1 = "metric=test\n" -"metric/test/name=test\n" +"metric/test/metric_name=test\n" "metric/test/event_name=test\n" "\n"; diff --git a/src/stats/test-stats-metrics.c b/src/stats/test-stats-metrics.c index 558ad7bbbb..1a2b270c19 100644 --- a/src/stats/test-stats-metrics.c +++ b/src/stats/test-stats-metrics.c @@ -19,7 +19,7 @@ bool test_stats_callback(struct event *event, static const char *settings_blob_1 = "metric=test\n" -"metric/test/name=test\n" +"metric/test/metric_name=test\n" "metric/test/event_name=test\n" "\n"; @@ -46,7 +46,7 @@ static void test_stats_metrics(void) static const char *settings_blob_2 = "metric=test\n" -"metric/test/name=test\n" +"metric/test/metric_name=test\n" "metric/test/event_name=test\n" "metric/test/filter=\n" "metric/test/filter/test_field=value\n" @@ -168,7 +168,7 @@ static void test_stats_metrics_group_by_discrete_real(const struct discrete_test test->settings_blob)); test_init(t_strdup_printf("metric=test\n" - "metric/test/name=test\n" + "metric/test/metric_name=test\n" "metric/test/event_name=test\n" "metric/test/group_by=%s\n" "\n", test->settings_blob)); @@ -344,7 +344,7 @@ static void test_stats_metrics_group_by_quantized_real(const struct quantized_te test->settings_blob)); test_init(t_strdup_printf("metric=test\n" - "metric/test/name=test\n" + "metric/test/metric_name=test\n" "metric/test/event_name=test\n" "metric/test/group_by=test_name foobar:%s\n" "\n", test->settings_blob));