2.1.1.4 : Transmission and reception of statistics
Periodic sending. Inside the main event loop of run(), a timer (p_statTimer) fires every stat_timer_period milliseconds (configurable per daemon). At each tick, sendStatToStatDaemon() is called:
- A DaemonStat object is created and populated by fillDaemonStat(): each StatAccumulator is converted into a VecStat containing nb events, min, max, average, rate (events/s), per-bin rates, and out-of-bound rates, stamped with a start and end timestamp.
- The DaemonStat is sent to the daemon named stat_daemon_name (configured in the [statistics] section of the TOML file) via sendValue.
- All accumulators are reset (clearStat()) and the start timestamp is updated.
Reception by StatDaemonManager. The StatDaemonManager is itself a Daemon. During initialisation (addCallMethod), it registers sortFillDaemonStat as the data callback for the type DaemonStat:
- When a DaemonStat message arrives, the framework automatically calls sortFillDaemonStat.
- This function calls fillStatInfo, which stores the received DaemonStat in the internal map p_mapDaemonStat, indexed by the daemon name.
- Any previously received entry for that daemon is silently overwritten with the latest report.