Change in libosmocore[master]: refactor stat_item: report only changed values

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Wed Sep 15 06:40:37 UTC 2021


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/25465 )


Change subject: refactor stat_item: report only changed values
......................................................................

refactor stat_item: report only changed values

Change the functionality of skipping unchanged values: instead of
looking up whether new values have been set on a stat item, rather
remember the last reported value and skip reporting identical values.

stats_test.c shows that previously, a stat item reported a value of 10
again, even though the previous report had already sent a value of 10.
That's just because the value 10 was explicitly set again, internally.

>From a perspective of preserving all data points, it could make sense to
send consecutive identical values. But since we already collapse all
data points per reporting period into a max, that is pointless.

Related: SYS#5542
Change-Id: I8f4cf34dfed17e0879716fa2cbeee137c158978b
---
M TODO-RELEASE
M src/stats.c
M tests/stats/stats_test.c
M tests/stats/stats_test.err
4 files changed, 9 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/65/25465/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 855ceaa..45371db 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -17,3 +17,4 @@
 libosmgsm      kdf functions   New API
 libosmocore	osmo_stat_item		API change and ABI breakage due to new struct members; some osmo_stat_item API deprecated.
 libosmocore	osmo_stat_item		No FIFO buffer of values used anymore, the "skipped values" error is no longer possible.
+libosmocore	stats reporting		for osmo_stat_item, values are now never repeated from one stats report to the next.
diff --git a/src/stats.c b/src/stats.c
index f9a3bbc..41b2a6a 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -698,15 +698,11 @@
 		if (!srep->running)
 			continue;
 
-		/* If no new stat values have been set in the current reporting period, skip resending the value.
-		 * However, if the previously sent value is not the same as the current value, then do send the changed
-		 * value (while n == 0, the last value from the previous reporting period is in item->value.max == .last
-		 * == .min, which was put in new_value above).
-		 * Also if the stats reporter is set to resend all values, also do resend the current value regardless
-		 * of repetitions.
+		/* If the previously reported value is the same as the current value, skip resending the value.
+		 * However, if the stats reporter is set to resend all values, do resend the current value regardless of
+		 * repetitions.
 		 */
-		if ((!item->value.n && new_value == prev_reported_value)
-		    && !srep->force_single_flush)
+		if (new_value == prev_reported_value && !srep->force_single_flush)
 			continue;
 
 		if (!osmo_stats_reporter_check_config(srep,
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c
index 23025d1..48318a5 100644
--- a/tests/stats/stats_test.c
+++ b/tests/stats/stats_test.c
@@ -449,10 +449,10 @@
 	osmo_stat_item_set(osmo_stat_item_group_get_item(statg1, TEST_A_ITEM), 10);
 	do_report(0, 2);
 
-	fprintf(stderr, "report (group 1, item 1 update twice):\n");
+	fprintf(stderr, "report (group 1, item 1 update twice, with same value):\n");
 	osmo_stat_item_set(osmo_stat_item_group_get_item(statg1, TEST_A_ITEM), 10);
 	osmo_stat_item_set(osmo_stat_item_group_get_item(statg1, TEST_A_ITEM), 10);
-	do_report(0, 2);
+	do_report(0, 0);
 
 	fprintf(stderr, "report (group 1, item 1 update twice, check max):\n");
 	osmo_stat_item_set(osmo_stat_item_group_get_item(statg1, TEST_A_ITEM), 20);
diff --git a/tests/stats/stats_test.err b/tests/stats/stats_test.err
index a890e0f..1e604d1 100644
--- a/tests/stats/stats_test.err
+++ b/tests/stats/stats_test.err
@@ -114,10 +114,8 @@
   test2: item p= g=test.one i=1 n=item.a v=10 u=ma
   test1: item p= g=test.one i=1 n=item.a v=10 u=ma
 reported: 0 counter vals, 2 stat item vals
-report (group 1, item 1 update twice):
-  test2: item p= g=test.one i=1 n=item.a v=10 u=ma
-  test1: item p= g=test.one i=1 n=item.a v=10 u=ma
-reported: 0 counter vals, 2 stat item vals
+report (group 1, item 1 update twice, with same value):
+reported: 0 counter vals, 0 stat item vals
 report (group 1, item 1 update twice, check max):
   test2: item p= g=test.one i=1 n=item.a v=20 u=ma
   test1: item p= g=test.one i=1 n=item.a v=20 u=ma

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/25465
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8f4cf34dfed17e0879716fa2cbeee137c158978b
Gerrit-Change-Number: 25465
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210915/c33783df/attachment.htm>


More information about the gerrit-log mailing list