telemetry: Run callbacks at collect time

Calling collect_metrics() from a script would not invoke metric
callbacks, resulting in most of the process metrics to be zero
when a Zeek process isn't scraped via Prometheus.

Fixes #4309
This commit is contained in:
Arne Welzel 2025-03-26 11:42:52 +01:00
parent 33d7e5a7bf
commit c3c6ee5a2b
4 changed files with 58 additions and 6 deletions

View file

@ -264,6 +264,11 @@ private:
*/
void InvokeTelemetrySyncHook();
/**
* Runs the telemetry sync hooks and metric callbacks.
*/
void UpdateMetrics();
bool in_sync_hook = false;
std::map<std::string, std::shared_ptr<MetricFamily>> families;