[Asterisk-code-review] StatsD: Send stuff to the StatsD server and test (asterisk[master])

Tyler Cambron asteriskteam at digium.com
Thu Oct 29 15:36:53 CDT 2015


Tyler Cambron has uploaded a new change for review.

  https://gerrit.asterisk.org/1542

Change subject: StatsD: Send stuff to the StatsD server and test
......................................................................

StatsD: Send stuff to the StatsD server and test

Added code to allow the StatsD dialplan application to
send data to the server specified in statsd.conf.

ASTERISK-25419

Change-Id: I400db2f37c6ddf61515ff5a019646e36dcd0f922
---
M apps/app_statsd.c
1 file changed, 7 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/42/1542/2

diff --git a/apps/app_statsd.c b/apps/app_statsd.c
index 77e5116..33f5637 100644
--- a/apps/app_statsd.c
+++ b/apps/app_statsd.c
@@ -33,6 +33,7 @@
 #include "asterisk/app.h"
 #include "asterisk/pbx.h"
 #include "asterisk/strings.h"
+#include "asterisk/statsd.h"
 
 /*** DOCUMENTATION
 	<application name="StatsD" language="en_US">
@@ -76,7 +77,7 @@
 {
 	double numerical_value = strtod(value, NULL);
 
-	if (!strcmp(metric, "counter")) {
+	if (!strcmp(metric, "c")) {
 		if (numerical_value < pow(-2, 63) || numerical_value > pow(2, 63)) {
 			ast_log(AST_LOG_WARNING, "Value %lf out of range!\n", numerical_value);
 			return 1;
@@ -104,7 +105,7 @@
  */
 static int validate_metric(const char *metric)
 {
-	const char *valid_metrics[] = {"gauge","set","timer","counter"};
+	const char *valid_metrics[] = {"g","s","ms","c"};
 	int i;
 
 	if (ast_strlen_zero(metric)) {
@@ -168,7 +169,7 @@
 		return 1;
 	}
 
-	if (!strcmp(metric, "gauge") || !strcmp(metric, "counter")) {
+	if (!strcmp(metric, "g") || !strcmp(metric, "c")) {
 		if ((value[0] == '+') || (value[0] == '-')) {
 			actual_value = &value[1];
 			if (ast_strlen_zero(actual_value)) {
@@ -223,6 +224,9 @@
 		return 1;
 	}
 
+	double numerical_value = strtod(args.value, NULL);
+	ast_statsd_log(args.statistic_name, args.metric_type, numerical_value);
+
 	return 0;
 }
 

-- 
To view, visit https://gerrit.asterisk.org/1542
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I400db2f37c6ddf61515ff5a019646e36dcd0f922
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Tyler Cambron <tcambron at digium.com>



More information about the asterisk-code-review mailing list