summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9c7fee6)
raw | patch | inline | side by side (parent: 9c7fee6)
author | Marc Fournier <marc.fournier@camptocamp.com> | |
Fri, 26 Jul 2013 15:35:44 +0000 (17:35 +0200) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Wed, 14 Aug 2013 14:33:37 +0000 (16:33 +0200) |
The "count" name was chosen over "num" to match the naming scheme
used by the node.js implementation.
used by the node.js implementation.
src/statsd.c | patch | blob | history | |
src/utils_latency.c | patch | blob | history | |
src/utils_latency.h | patch | blob | history |
diff --git a/src/statsd.c b/src/statsd.c
index 731a6e8c4e8548e37c3f8798c536580a5d63e145..72a7779b929b11a1577b75e6276bc658ac1ee054 100644 (file)
--- a/src/statsd.c
+++ b/src/statsd.c
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, /* {{{ */
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
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);
}
diff --git a/src/utils_latency.c b/src/utils_latency.c
index 4a250c33a4143730f1609da50af3ac428855c79a..94da2112ec1971410f9b54870b9694ac35388b84 100644 (file)
--- a/src/utils_latency.c
+++ b/src/utils_latency.c
return (lc->sum);
} /* }}} cdtime_t latency_counter_get_sum */
+size_t latency_counter_get_num (latency_counter_t *lc) /* {{{ */
+{
+ if (lc == NULL)
+ return (0);
+ return (lc->num);
+} /* }}} size_t latency_counter_get_num */
+
cdtime_t latency_counter_get_average (latency_counter_t *lc) /* {{{ */
{
double average;
diff --git a/src/utils_latency.h b/src/utils_latency.h
index 352a4ec3a4fedf42798d130c54c2e6fcbec894cf..3787c779434c191957fe60a8fefae1063567e9a2 100644 (file)
--- a/src/utils_latency.h
+++ b/src/utils_latency.h
cdtime_t latency_counter_get_min (latency_counter_t *lc);
cdtime_t latency_counter_get_max (latency_counter_t *lc);
cdtime_t latency_counter_get_sum (latency_counter_t *lc);
+size_t latency_counter_get_num (latency_counter_t *lc);
cdtime_t latency_counter_get_average (latency_counter_t *lc);
cdtime_t latency_counter_get_percentile (latency_counter_t *lc,
double percent);