From: Pierre-Yves Ritschard Date: Mon, 19 Oct 2015 09:53:26 +0000 (+0200) Subject: statsd: provide a gauge for counters, holding the absolute count. X-Git-Tag: collectd-5.6.0~583^2 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=c9b786d2a55ed1bde46e09ea02a10cb0b12a2e5b statsd: provide a gauge for counters, holding the absolute count. When not using StoreRates false, this allows statsd aggregators to hold on to the absolute count, if needed. --- diff --git a/src/statsd.c b/src/statsd.c index 9a6da1d3..3ec1d9e9 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -850,8 +850,19 @@ static int statsd_metric_submit_unsafe (char const *name, /* {{{ */ else values[0].gauge = (gauge_t) c_avl_size (metric->set); } - else - values[0].derive = (derive_t) metric->value; + else { /* STATSD_COUNTER */ + /* + * Expand a single value to two metrics: + * + * - The absolute counter, as a gauge + * - A derived rate for this counter + */ + values[0].derive = (derive_t) metric->value; + plugin_dispatch_values(&vl); + + sstrncpy(vl.type, "gauge", sizeof (vl.type)); + values[0].gauge = (gauge_t) metric->value; + } return (plugin_dispatch_values (&vl)); } /* }}} int statsd_metric_submit_unsafe */