diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2021-03-01 21:53:46 +0100 |
---|---|---|
committer | Daniel Willmann <dwillmann@sysmocom.de> | 2021-03-09 14:08:15 +0100 |
commit | 2aa527bd99c93b472ee95173660b17c2021e9367 (patch) | |
tree | 36fb17a80e9320c4e7a2372088ea5f81b484d59b /tests/stats/stats_test.c | |
parent | 24920e2c9747ef73e9233d11fb91acccb8f0beb6 (diff) |
stats: Ensure that each osmo_stat_item only reports once per interval
We should never report multiple values for a metric. It is confusing for
the log reporter and wrong for statsd. Statsd will record only one value,
but will it be the first, last, ...?
This can happen if an osmo_stat_item changes more than once within the
same reporting interval.
With this patch only one aggregate value is sent to the log reporters.
The value reported is the maximum during this interval. Other
aggregations could be possible (min, last), but reporting a (useful)
average is not because the values don't include a timestamp and most
osmo_stat_items change at unregular intervals.
Change-Id: I366ab1c66f4ae6363111ea4e41b66b7d5bcade9c
Related: SYS#4877
Diffstat (limited to 'tests/stats/stats_test.c')
-rw-r--r-- | tests/stats/stats_test.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c index 71f710a9..05caf982 100644 --- a/tests/stats/stats_test.c +++ b/tests/stats/stats_test.c @@ -440,6 +440,20 @@ static void test_reporting() osmo_stats_report(); OSMO_ASSERT(send_count == 2); + printf("report (group 1, item 1 update twice):\n"); + osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); + osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); + send_count = 0; + osmo_stats_report(); + OSMO_ASSERT(send_count == 2); + + printf("report (group 1, item 1 update twice, check max):\n"); + osmo_stat_item_set(statg1->items[TEST_A_ITEM], 20); + osmo_stat_item_set(statg1->items[TEST_A_ITEM], 10); + send_count = 0; + osmo_stats_report(); + OSMO_ASSERT(send_count == 2); + printf("report (remove statg1, ctrg1):\n"); /* force single flush */ srep1->force_single_flush = 1; |