summaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-27 15:10:28 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-10-29 01:10:07 +0100
commit490b38f57a24726f3e3493fc3500cda526c5d0aa (patch)
treea0b31dc95460e9e9a71c271b19b5536f0156f008 /include/osmocom
parented197fd4f923512fca5b93b90c2132845896fa59 (diff)
stats: Use function pointers in reporter objects
Currently case statements are used to select the right reporter functions. This makes it difficult to add new reporter types, especially if they are not going to reside in the same file. This commit introduces per reporter function pointer for open, close, send_count, and send_item. They are checked for non-NULL before being called or skipped. Sponsored-by: On-Waves ehf
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/core/stats.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h
index 9ee9f106..beeee16e 100644
--- a/include/osmocom/core/stats.h
+++ b/include/osmocom/core/stats.h
@@ -23,6 +23,10 @@
#include <osmocom/core/linuxlist.h>
struct msgb;
+struct stat_item_group;
+struct stat_item_desc;
+struct rate_ctr_group;
+struct rate_ctr_desc;
enum stats_reporter_type {
STATS_REPORTER_STATSD,
@@ -53,6 +57,16 @@ struct stats_reporter {
int agg_enabled;
struct llist_head list;
+ int (*open)(struct stats_reporter *srep);
+ int (*close)(struct stats_reporter *srep);
+ int (*send_counter)(struct stats_reporter *srep,
+ const struct rate_ctr_group *ctrg,
+ const struct rate_ctr_desc *desc,
+ int64_t value, int64_t delta);
+ int (*send_item)(struct stats_reporter *srep,
+ const struct stat_item_group *statg,
+ const struct stat_item_desc *desc,
+ int32_t value);
};
struct stats_config {