libosmocore/src/core/stat_item_internal.h

36 lines
1.1 KiB
C
Raw Normal View History

refactor stat_item: get rid of FIFO and "skipped" error Intead of attempting to store all distinct values of a reporting period, just store min, max, last as well as a sum and N of each reporting period. This gets rid of error messages like DLSTATS ERROR stat_item.c:285 num_bts:oml_connected: 44 stats values skipped while at the same time more accurately reporting the max value for each reporting period. (So far stats_item only reports the max value; keep that part unchanged, as shown in stats_test.c.) With the other so far unused values (min, sum), we are ready to also report the minimum value as well as an average value per reporting period in the future, if/when our stats reporter allows for it. Store the complete record of the previous reporting period. So far we only compare the 'max' value, but like this we are ready to also see changes in min, last and average value between reporting periods. This patch breaks API by removing: - struct members osmo_stats_item.stats_next_id, .last_offs and .values[] - struct osmo_stats_item_value - osmo_stat_item_get_next() - osmo_stat_item_discard() - osmo_stat_item_discard_all() and by making struct osmo_stats_item opaque. In libosmocore, we do have a policy of never breaking API. But since the above should never be accessed by users of the osmo_stats_item API -- or if they are, would no longer yield useful results, we decided to make an exception in this case. The alternative would be to introduce a new osmo_stats_item2 API and maintaining an unused legacy osmo_stats_item forever, but we decided that the effort is not worth it. There are no known users of the removed items. Related: SYS#5542 Change-Id: I137992a5479fc39bbceb6c6c2af9c227bd33b39b
2021-09-14 12:37:38 +00:00
/*! \file stat_item_internal.h
* internal definitions for the osmo_stat_item API */
#pragma once
/*! \addtogroup osmo_stat_item
* @{
*/
struct osmo_stat_item_period {
/*! Number of osmo_stat_item_set() that occurred during the reporting period, zero if none. */
uint32_t n;
/*! Smallest value seen in a reporting period. */
int32_t min;
/*! Most recent value passed to osmo_stat_item_set(), or the item->desc->default_value if none. */
int32_t last;
/*! Largest value seen in a reporting period. */
int32_t max;
/*! Sum of all values passed to osmo_stat_item_set() in the reporting period. */
int64_t sum;
};
/*! data we keep for each actual item */
struct osmo_stat_item {
/*! back-reference to the item description */
const struct osmo_stat_item_desc *desc;
/*! Current reporting period / current value. */
struct osmo_stat_item_period value;
/*! The results of the previous reporting period. According to these, the stats reporter decides whether to
* re-send values or omit an unchanged value from a report. */
struct osmo_stat_item_period reported;
};
/*! @} */