telemetry: Move callbacks to Zeek

Now that we run callbacks on the main loop, we can move callback support
for Counter and Gauge instances directly into Zeek and don't need to patch
prometheus-cpp anymore.
This commit is contained in:
Arne Welzel 2024-09-11 17:49:06 +02:00
parent c7fcdc4050
commit 48dd89ef33
15 changed files with 143 additions and 186 deletions

View file

@ -435,13 +435,9 @@ Manager::~Manager() { delete pending; }
void Manager::InitPostScript() {
trigger_count = telemetry_mgr->CounterInstance("zeek", "triggers", {}, "Total number of triggers scheduled");
trigger_pending =
telemetry_mgr->GaugeInstance("zeek", "pending_triggers", {}, "Pending number of triggers", "",
[]() -> prometheus::ClientMetric {
prometheus::ClientMetric metric;
metric.gauge.value =
trigger_mgr ? static_cast<double>(trigger_mgr->pending->size()) : 0.0;
return metric;
});
telemetry_mgr->GaugeInstance("zeek", "pending_triggers", {}, "Pending number of triggers", "", []() {
return trigger_mgr ? static_cast<double>(trigger_mgr->pending->size()) : 0.0;
});
iosource_mgr->Register(this, true);
}