Code

Merge remote-tracking branch 'github/pr/2040'
[collectd.git] / src / daemon / utils_match.c
index 914b6e278c746c1dd04e44a603894377f3991c0c..35102b6dec76b78e5062156dda586c3d773daae6 100644 (file)
@@ -100,7 +100,8 @@ static int default_callback (const char __attribute__((unused)) *str,
       return (-1);
 
     if ((data->values_num == 0)
-       || (data->ds_type & UTILS_MATCH_CF_GAUGE_LAST))
+       || (data->ds_type & UTILS_MATCH_CF_GAUGE_LAST)
+       || (data->ds_type & UTILS_MATCH_CF_GAUGE_PERSIST))
     {
       data->value.gauge = value;
     }
@@ -298,7 +299,9 @@ void match_value_reset (cu_match_value_t *mv)
   if (mv == NULL)
     return;
 
-  if (mv->ds_type & UTILS_MATCH_DS_TYPE_GAUGE)
+  /* Reset GAUGE metrics only and except GAUGE_PERSIST. */
+  if ((mv->ds_type & UTILS_MATCH_DS_TYPE_GAUGE)
+      && !(mv->ds_type & UTILS_MATCH_CF_GAUGE_PERSIST))
   {
     mv->value.gauge = NAN;
     mv->values_num = 0;