mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add telemetry Manager to Zeek setup / teardown
This commit is contained in:
parent
83d7d2da4c
commit
443f7f0a18
3 changed files with 39 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
#include "zeek/Func.h"
|
||||
#include "zeek/broker/Data.h"
|
||||
#include "zeek/broker/Store.h"
|
||||
#include "zeek/telemetry/Manager.h"
|
||||
#include "zeek/util.h"
|
||||
#include "zeek/Var.h"
|
||||
#include "zeek/Desc.h"
|
||||
|
@ -1806,4 +1807,31 @@ void Manager::PrepareForwarding(const std::string &name)
|
|||
DBG_LOG(DBG_BROKER, "Resolved table forward for data store %s", name.c_str());
|
||||
}
|
||||
|
||||
std::unique_ptr<telemetry::Manager> Manager::NewTelemetryManager()
|
||||
{
|
||||
// The telemetry Manager actually only has a dependency on the actor system,
|
||||
// not to the Broker Manager. By having the telemetry Manager hold on to a
|
||||
// shared_ptr to our Broker state, we make sure the Broker endpoint, which
|
||||
// owns the CAF actor system, lives for as long as necessary. This also
|
||||
// makes sure that the Broker Manager may even get destroyed before the
|
||||
// telemetry Manager.
|
||||
struct TM : public telemetry::Manager
|
||||
{
|
||||
static auto getPimpl(BrokerState& st)
|
||||
{
|
||||
auto registry = std::addressof(st.endpoint.system().metrics());
|
||||
return reinterpret_cast<telemetry::Manager::Impl*>(registry);
|
||||
}
|
||||
|
||||
explicit TM(const std::shared_ptr<BrokerState>& bsptr)
|
||||
: telemetry::Manager(getPimpl(*bsptr)), ptr(bsptr)
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<BrokerState> ptr;
|
||||
};
|
||||
|
||||
return std::make_unique<TM>(bstate);
|
||||
}
|
||||
|
||||
} // namespace zeek::Broker
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue