Add no-workers option to statsd plugin

This commit is contained in:
Marek Wiewiorski
2015-08-25 15:58:15 +02:00
parent 59df10466a
commit 82a011e14d
+13 -1
View File
@@ -16,6 +16,14 @@ it exports values exposed by the metric subsystem
extern struct uwsgi_server uwsgi;
struct uwsgi_stats_pusher_statsd {
int no_workers;
} u_stats_pusher_statsd;
static struct uwsgi_option stats_pusher_statsd_options[] = {
{"statsd-no-workers", no_argument, 0, "disable generation of single worker metrics", uwsgi_opt_true, &u_stats_pusher_statsd.no_workers, 0}
};
// configuration of a statsd node
struct statsd_node {
int fd;
@@ -88,7 +96,10 @@ static void stats_pusher_statsd(struct uwsgi_stats_pusher_instance *uspi, time_t
while(um) {
uwsgi_rlock(uwsgi.metrics_lock);
// ignore return value
if (um->type == UWSGI_METRIC_GAUGE) {
if (u_stats_pusher_statsd.no_workers && strstr(um->name, "worker.") != NULL) {
// no-op
}
else if (um->type == UWSGI_METRIC_GAUGE) {
statsd_send_metric(ub, uspi, um->name, um->name_len, *um->value, "|g");
}
else {
@@ -114,6 +125,7 @@ static void stats_pusher_statsd_init(void) {
struct uwsgi_plugin stats_pusher_statsd_plugin = {
.name = "stats_pusher_statsd",
.options = stats_pusher_statsd_options,
.on_load = stats_pusher_statsd_init,
};