From cf872835b60a3ec683b428832fbc79d6aa2df939 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Ritschard Date: Mon, 19 Oct 2015 11:53:26 +0200 Subject: [PATCH 1/1] 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. --- src/statsd.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/statsd.c b/src/statsd.c index 1512b866..96c471d2 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -846,8 +846,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 */ -- 2.11.0