Add a unified observability interface for applications with multiple networks
🧪 Test / test (push) Successful in 6m9s
🧪 Test / test (push) Successful in 6m9s
This commit is contained in:
@@ -110,14 +110,16 @@ public:
|
||||
for (auto* n : user_nodes_topo_) n->start();
|
||||
for (auto* n : fanout_nodes_ptr_) n->start();
|
||||
#ifdef KPN_WEB_DEBUG
|
||||
web_server_ = std::make_unique<web_debug::WebDebugServer>(
|
||||
web_debug_port_,
|
||||
[this]() {
|
||||
auto s = collect_snapshots();
|
||||
return web_debug::to_json(s.nodes, s.channels, s.resources, s.elapsed_s);
|
||||
});
|
||||
web_server_->start();
|
||||
std::cerr << "[kpn] web debug UI: http://localhost:" << web_debug_port_ << "\n";
|
||||
if (web_server_enabled_) {
|
||||
web_server_ = std::make_unique<web_debug::WebDebugServer>(
|
||||
web_debug_port_,
|
||||
[this]() {
|
||||
auto s = collect_snapshots();
|
||||
return web_debug::to_json(s.nodes, s.channels, s.resources, s.elapsed_s);
|
||||
});
|
||||
web_server_->start();
|
||||
std::cerr << "[kpn] web debug UI: http://localhost:" << web_debug_port_ << "\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -142,8 +144,16 @@ public:
|
||||
|
||||
#ifdef KPN_WEB_DEBUG
|
||||
void set_web_debug_port(uint16_t port) { web_debug_port_ = port; }
|
||||
// Called by DebugHub::register_network() so the hub owns the debug server.
|
||||
void disable_web_server() { web_server_enabled_ = false; }
|
||||
#endif
|
||||
|
||||
// Returns a snapshot of this network's nodes and channels for the DebugHub.
|
||||
NetworkSnapshot network_snapshot() const {
|
||||
auto s = collect_snapshots();
|
||||
return {"", std::move(s.nodes), std::move(s.channels), s.elapsed_s};
|
||||
}
|
||||
|
||||
// Register a shared resource so it appears in diagnostics and the debug UI.
|
||||
// The probe must outlive this network (typically the resource is on the same stack).
|
||||
void register_resource(const std::string& name, IResourceProbe* probe) {
|
||||
@@ -205,6 +215,7 @@ private:
|
||||
clock_t::time_point start_time_;
|
||||
#ifdef KPN_WEB_DEBUG
|
||||
uint16_t web_debug_port_{9090};
|
||||
bool web_server_enabled_{true};
|
||||
std::unique_ptr<web_debug::WebDebugServer> web_server_;
|
||||
#endif
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user