From af5bad5ed00f0d21617c34f0e4e96eb2fd977a02 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Fri, 27 Nov 2015 18:54:58 +0100 Subject: stat: Explicitly support stat_items without unit Add OSMO_STAT_ITEM_NO_UNIT for stat items without an unit. The statsd reporter uses gauges ("g") to report them. Sponsored-by: On-Waves ehf --- src/stats_statsd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/stats_statsd.c') diff --git a/src/stats_statsd.c b/src/stats_statsd.c index c76f8f69..b93d90a7 100644 --- a/src/stats_statsd.c +++ b/src/stats_statsd.c @@ -151,8 +151,18 @@ static int osmo_stats_reporter_statsd_send_item(struct osmo_stats_reporter *srep const struct osmo_stat_item_group *statg, const struct osmo_stat_item_desc *desc, int value) { + char *unit = desc->unit; + + if (unit == OSMO_STAT_ITEM_NO_UNIT) { + unit = "g"; + if (value < 0) + osmo_stats_reporter_statsd_send(srep, + statg->desc->group_name_prefix, + statg->idx, + desc->name, 0, unit); + } return osmo_stats_reporter_statsd_send(srep, statg->desc->group_name_prefix, statg->idx, - desc->name, value, desc->unit); + desc->name, value, unit); } -- cgit v1.2.3