X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fstatsd.c;h=72a7779b929b11a1577b75e6276bc658ac1ee054;hb=d7c0080fdca2a6cdc45aba04e27fa7e23a627ca8;hp=1045aeaa8474ee78605f7878c9abe40b220f64b1;hpb=1b750eb50cb50e62338e380217191a71d92088d4;p=collectd.git diff --git a/src/statsd.c b/src/statsd.c index 1045aeaa..72a7779b 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -81,6 +81,8 @@ static size_t conf_timer_percentile_num = 0; static _Bool conf_timer_lower = 0; static _Bool conf_timer_upper = 0; +static _Bool conf_timer_sum = 0; +static _Bool conf_timer_count = 0; /* Must hold metrics_lock when calling this function. */ static statsd_metric_t *statsd_metric_lookup_unsafe (char const *name, /* {{{ */ @@ -632,6 +634,10 @@ static int statsd_config (oconfig_item_t *ci) /* {{{ */ cf_util_get_boolean (child, &conf_timer_lower); else if (strcasecmp ("TimerUpper", child->key) == 0) cf_util_get_boolean (child, &conf_timer_upper); + else if (strcasecmp ("TimerSum", child->key) == 0) + cf_util_get_boolean (child, &conf_timer_sum); + else if (strcasecmp ("TimerCount", child->key) == 0) + cf_util_get_boolean (child, &conf_timer_count); else if (strcasecmp ("TimerPercentile", child->key) == 0) statsd_config_timer_percentile (child); else @@ -749,6 +755,14 @@ static int statsd_metric_submit_unsafe (char const *name, /* {{{ */ plugin_dispatch_values (&vl); } + if (conf_timer_sum) { + ssnprintf (vl.type_instance, sizeof (vl.type_instance), + "%s-sum", name); + values[0].gauge = CDTIME_T_TO_DOUBLE ( + latency_counter_get_sum (metric->latency)); + plugin_dispatch_values (&vl); + } + for (i = 0; i < conf_timer_percentile_num; i++) { ssnprintf (vl.type_instance, sizeof (vl.type_instance), @@ -759,6 +773,16 @@ static int statsd_metric_submit_unsafe (char const *name, /* {{{ */ plugin_dispatch_values (&vl); } + /* Keep this at the end, since vl.type is set to "gauge" here. The + * vl.type's above are implicitly set to "latency". */ + if (conf_timer_count) { + sstrncpy (vl.type, "gauge", sizeof (vl.type)); + ssnprintf (vl.type_instance, sizeof (vl.type_instance), + "%s-count", name); + values[0].gauge = latency_counter_get_num (metric->latency); + plugin_dispatch_values (&vl); + } + latency_counter_reset (metric->latency); return (0); }