mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +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
|
@ -2,12 +2,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "zeek/Type.h"
|
||||
#include "zeek/ZeekArgs.h"
|
||||
#include "zeek/ZeekList.h"
|
||||
#include "zeek/telemetry/Counter.h"
|
||||
|
||||
namespace zeek
|
||||
{
|
||||
|
@ -55,7 +57,7 @@ public:
|
|||
}
|
||||
bool GenerateAlways() const { return generate_always; }
|
||||
|
||||
uint64_t CallCount() const { return call_count; }
|
||||
uint64_t CallCount() const { return call_count ? call_count->Value() : 0; }
|
||||
|
||||
private:
|
||||
void NewEvent(zeek::Args* vl); // Raise new_event() meta event.
|
||||
|
@ -67,7 +69,9 @@ private:
|
|||
bool enabled;
|
||||
bool error_handler; // this handler reports error messages.
|
||||
bool generate_always;
|
||||
uint64_t call_count = 0;
|
||||
|
||||
// Initialize this lazy, so we don't expose metrics for 0 values.
|
||||
std::optional<zeek::telemetry::IntCounter> call_count;
|
||||
|
||||
std::unordered_set<std::string> auto_publish;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue