tail plugin, latency: Fix regressions after #2535
authorPavel Rochnyack <pavel2000@ngs.ru>
Sun, 10 Dec 2017 17:14:01 +0000 (17:14 +0000)
committerPavel Rochnyack <pavel2000@ngs.ru>
Thu, 14 Dec 2017 14:30:16 +0000 (14:30 +0000)
 - Remove two fixed decimal places from type instance of percentiles
 - Recover accuracy of bounds in type instance of buckets
 + Allow (compared to state before #2535) to report percentiles with fractional values
 * Changed maximum length of reported type and type instance to 50 chars

References: #2535
Closes: #2587

src/utils_tail_match.c

index 79868fc..5134a6e 100644 (file)
@@ -118,10 +118,10 @@ static int latency_submit_match(cu_match_t *match, void *user_data) {
   sstrncpy(vl.type, data->type, sizeof(vl.type));
   for (size_t i = 0; i < data->latency_config.percentile_num; i++) {
     if (strlen(data->type_instance) != 0)
-      snprintf(vl.type_instance, sizeof(vl.type_instance), "%.117s-%.2f",
+      snprintf(vl.type_instance, sizeof(vl.type_instance), "%.50s-%.5g",
                data->type_instance, data->latency_config.percentile[i]);
     else
-      snprintf(vl.type_instance, sizeof(vl.type_instance), "%.0f",
+      snprintf(vl.type_instance, sizeof(vl.type_instance), "%.5g",
                data->latency_config.percentile[i]);
 
     vl.values = &(value_t){
@@ -150,11 +150,10 @@ static int latency_submit_match(cu_match_t *match, void *user_data) {
         bucket.upper_bound ? CDTIME_T_TO_DOUBLE(bucket.upper_bound) : INFINITY;
 
     if (strlen(data->type_instance) != 0)
-      snprintf(vl.type_instance, sizeof(vl.type_instance),
-               "%.54s-%.54s-%.2g_%.2g", data->type, data->type_instance,
-               lower_bound, upper_bound);
+      snprintf(vl.type_instance, sizeof(vl.type_instance), "%.50s-%.50s-%g_%g",
+               data->type, data->type_instance, lower_bound, upper_bound);
     else
-      snprintf(vl.type_instance, sizeof(vl.type_instance), "%.107s-%.2g_%.2g",
+      snprintf(vl.type_instance, sizeof(vl.type_instance), "%.50s-%g_%g",
                data->type, lower_bound, upper_bound);
 
     vl.values = &(value_t){