Rework telemetry config
This commit is contained in:
parent
6a01a97f65
commit
e8d125877e
3 changed files with 20 additions and 20 deletions
|
|
@ -155,7 +155,7 @@ nano::node::node (std::shared_ptr<boost::asio::io_context> io_ctx_a, std::filesy
|
|||
// otherwise, any value is considered, with `0` having the special meaning of 'let the OS pick a port instead'
|
||||
//
|
||||
network (*this, config.peering_port.has_value () ? *config.peering_port : 0),
|
||||
telemetry{ nano::telemetry::config{ config, flags }, *this, network, observers, network_params, stats },
|
||||
telemetry{ flags, *this, network, observers, network_params, stats },
|
||||
bootstrap_initiator (*this),
|
||||
bootstrap_server{ config.bootstrap_server, store, ledger, network_params.network, stats },
|
||||
// BEWARE: `bootstrap` takes `network.port` instead of `config.peering_port` because when the user doesn't specify
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
nano::telemetry::telemetry (const config & config_a, nano::node & node_a, nano::network & network_a, nano::node_observers & observers_a, nano::network_params & network_params_a, nano::stats & stats_a) :
|
||||
config_m{ config_a },
|
||||
nano::telemetry::telemetry (nano::node_flags const & flags_a, nano::node & node_a, nano::network & network_a, nano::node_observers & observers_a, nano::network_params & network_params_a, nano::stats & stats_a) :
|
||||
config{ flags_a },
|
||||
node{ node_a },
|
||||
network{ network_a },
|
||||
observers{ observers_a },
|
||||
|
|
@ -150,7 +150,7 @@ bool nano::telemetry::request_predicate () const
|
|||
{
|
||||
return true;
|
||||
}
|
||||
if (config_m.enable_ongoing_requests)
|
||||
if (config.enable_ongoing_requests)
|
||||
{
|
||||
return last_request + network_params.network.telemetry_request_interval < std::chrono::steady_clock::now ();
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ bool nano::telemetry::broadcast_predicate () const
|
|||
{
|
||||
debug_assert (!mutex.try_lock ());
|
||||
|
||||
if (config_m.enable_ongoing_broadcasts)
|
||||
if (config.enable_ongoing_broadcasts)
|
||||
{
|
||||
return last_broadcast + network_params.network.telemetry_broadcast_interval < std::chrono::steady_clock::now ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,19 @@ namespace transport
|
|||
class channel;
|
||||
}
|
||||
|
||||
class telemetry_config final
|
||||
{
|
||||
public:
|
||||
bool enable_ongoing_requests{ false }; // TODO: No longer used, remove
|
||||
bool enable_ongoing_broadcasts{ true };
|
||||
|
||||
public:
|
||||
explicit telemetry_config (nano::node_flags const & flags) :
|
||||
enable_ongoing_broadcasts{ !flags.disable_providing_telemetry_metrics }
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This class periodically broadcasts and requests telemetry from peers.
|
||||
* Those intervals are configurable via `telemetry_request_interval` & `telemetry_broadcast_interval` network constants
|
||||
|
|
@ -43,19 +56,7 @@ namespace transport
|
|||
class telemetry
|
||||
{
|
||||
public:
|
||||
struct config
|
||||
{
|
||||
bool enable_ongoing_requests{ false };
|
||||
bool enable_ongoing_broadcasts{ true };
|
||||
|
||||
config (nano::node_config const & config, nano::node_flags const & flags) :
|
||||
enable_ongoing_broadcasts{ !flags.disable_providing_telemetry_metrics }
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
telemetry (config const &, nano::node &, nano::network &, nano::node_observers &, nano::network_params &, nano::stats &);
|
||||
telemetry (nano::node_flags const &, nano::node &, nano::network &, nano::node_observers &, nano::network_params &, nano::stats &);
|
||||
~telemetry ();
|
||||
|
||||
void start ();
|
||||
|
|
@ -87,14 +88,13 @@ public: // Container info
|
|||
std::unique_ptr<nano::container_info_component> collect_container_info (std::string const & name);
|
||||
|
||||
private: // Dependencies
|
||||
telemetry_config const config;
|
||||
nano::node & node;
|
||||
nano::network & network;
|
||||
nano::node_observers & observers;
|
||||
nano::network_params & network_params;
|
||||
nano::stats & stats;
|
||||
|
||||
const config config_m;
|
||||
|
||||
private:
|
||||
struct entry
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue