mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
EventHandler: Use telemetry framework for EventHandler.call_count
Put the IntCounter into a std::optional rather than initializing it at EventHandler construction time as that will currently expose a time series per event handler through the Prometheus API.
This commit is contained in:
parent
a40025b82d
commit
56a8b99965
4 changed files with 42 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
|||
#include "zeek/Var.h"
|
||||
#include "zeek/broker/Data.h"
|
||||
#include "zeek/broker/Manager.h"
|
||||
#include "zeek/telemetry/Manager.h"
|
||||
|
||||
namespace zeek
|
||||
{
|
||||
|
@ -53,7 +54,16 @@ void EventHandler::SetFunc(FuncPtr f)
|
|||
|
||||
void EventHandler::Call(Args* vl, bool no_remote)
|
||||
{
|
||||
call_count++;
|
||||
if ( ! call_count )
|
||||
{
|
||||
static auto eh_invocations_family = telemetry_mgr->CounterFamily(
|
||||
"zeek", "event-handler-invocations", {"name"},
|
||||
"Number of times the given event handler was called", "1", true);
|
||||
|
||||
call_count = eh_invocations_family.GetOrAdd({{"name", name}});
|
||||
}
|
||||
|
||||
call_count->Inc();
|
||||
|
||||
if ( new_event )
|
||||
NewEvent(vl);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue