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:
  1. 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.
  2. The DaemonStat is sent to the daemon named stat_daemon_name (configured in the [statistics] section of the TOML file) via sendValue.
  3. All accumulators are reset (clearStat()) and the start timestamp is updated.
A daemon does not send its own statistics to itself: if stat_daemon_name equals the current daemon's name, the sending step is skipped.

Reception by StatDaemonManager. The StatDaemonManager is itself a Daemon. During initialisation (addCallMethod), it registers sortFillDaemonStat as the data callback for the type DaemonStat:
  1. When a DaemonStat message arrives, the framework automatically calls sortFillDaemonStat.
  2. This function calls fillStatInfo, which stores the received DaemonStat in the internal map p_mapDaemonStat, indexed by the daemon name.
  3. Any previously received entry for that daemon is silently overwritten with the latest report.