From 42e4d6cd43374ac5e954a02408e7e79734c90f90 Mon Sep 17 00:00:00 2001 From: Dallin Young Date: Fri, 20 Feb 2015 19:33:00 +0100 Subject: [PATCH] write_tsdb plugin: Add type and type_instance to the metric name in any case. Previously, the generated names were wrong, especially when no plugin instance was used for a metric. Fixes: #945 Signed-off-by: Florian Forster --- src/write_tsdb.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/write_tsdb.c b/src/write_tsdb.c index b7f46f1b..bfac1a14 100644 --- a/src/write_tsdb.c +++ b/src/write_tsdb.c @@ -365,24 +365,32 @@ static int wt_format_name(char *ret, int ret_len, if (ds_name != NULL) { if (vl->plugin_instance[0] == '\0') { - ssnprintf(ret, ret_len, "%s%s.%s", - prefix, vl->plugin, ds_name); + if (vl->type_instance[0] == '\0') { + ssnprintf(ret, ret_len, "%s%s.%s.%s", + prefix, vl->plugin, vl->type, + ds_name); + } else { + ssnprintf(ret, ret_len, "%s%s.%s.%s", + prefix, vl->plugin, vl->type_instance, + ds_name); + } } else if (vl->type_instance[0] == '\0') { - ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", - prefix, vl->plugin, vl->plugin_instance, - vl->type_instance, ds_name); - } else { ssnprintf(ret, ret_len, "%s%s.%s.%s.%s", prefix, vl->plugin, vl->plugin_instance, vl->type, ds_name); + } else { + ssnprintf(ret, ret_len, "%s%s.%s.%s.%s.%s", + prefix, vl->plugin, vl->plugin_instance, vl->type, + vl->type_instance, ds_name); } } else if (vl->plugin_instance[0] == '\0') { - if (vl->type_instance[0] == '\0') + if (vl->type_instance[0] == '\0') { ssnprintf(ret, ret_len, "%s%s.%s", prefix, vl->plugin, vl->type); - else + } else { ssnprintf(ret, ret_len, "%s%s.%s", prefix, vl->plugin, vl->type_instance); + } } else if (vl->type_instance[0] == '\0') { ssnprintf(ret, ret_len, "%s%s.%s.%s", prefix, vl->plugin, vl->plugin_instance, vl->type); -- 2.30.2