aboutsummaryrefslogtreecommitdiffstats
path: root/src/stats.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-11-27 18:54:58 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-12-21 08:18:18 +0100
commit70fcbda6dd733a503e9a046e01986d8bfc2e2bb2 (patch)
tree0e3b05462c4258334212742e0bf4444e07728523 /src/stats.c
parent34d770dcfdb102bc5c5a22724b2386f5ce4b7a18 (diff)
stat: Explicitly support stat_items without unitzecke/ancient/debian6.0
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 [hfreyther: Manually apply change to osmo_stats_reporter_statsd_send_item]
Diffstat (limited to 'src/stats.c')
-rw-r--r--src/stats.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/stats.c b/src/stats.c
index 16e2971d..2ebac364 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -558,10 +558,20 @@ 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)
{
+ const 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);
}
/*** generic rate counter support ***/