From 26737308e00937f67544d80f30df0c3ba13ab5ba Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 3 Jan 2024 21:08:41 -0500 Subject: [PATCH 1/3] only register prometheus handlers when prometheus plugin enabled --- plugins/prometheus_plugin/prometheus_plugin.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/prometheus_plugin/prometheus_plugin.cpp b/plugins/prometheus_plugin/prometheus_plugin.cpp index ff929d282f..f0e4430daa 100644 --- a/plugins/prometheus_plugin/prometheus_plugin.cpp +++ b/plugins/prometheus_plugin/prometheus_plugin.cpp @@ -18,13 +18,9 @@ namespace eosio { struct prometheus_plugin_impl { eosio::chain::named_thread_pool _prometheus_thread_pool; - boost::asio::io_context::strand _prometheus_strand; + boost::asio::io_context::strand _prometheus_strand{_prometheus_thread_pool.get_executor()}; metrics::catalog_type _catalog; fc::microseconds _max_response_time_us; - - prometheus_plugin_impl(): _prometheus_strand(_prometheus_thread_pool.get_executor()){ - _catalog.register_update_handlers(_prometheus_strand); - } }; prometheus_plugin::prometheus_plugin() @@ -53,6 +49,7 @@ namespace eosio { void prometheus_plugin::plugin_initialize(const variables_map& options) { + my->_catalog.register_update_handlers(my->_prometheus_strand); auto& _http_plugin = app().get_plugin(); my->_max_response_time_us = _http_plugin.get_max_response_time(); From f5acb9eb864a80cdd885313fd128413b405a3622 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 3 Jan 2024 22:38:48 -0500 Subject: [PATCH 2/3] tweak syntax for clang --- plugins/prometheus_plugin/prometheus_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/prometheus_plugin/prometheus_plugin.cpp b/plugins/prometheus_plugin/prometheus_plugin.cpp index f0e4430daa..801cd46584 100644 --- a/plugins/prometheus_plugin/prometheus_plugin.cpp +++ b/plugins/prometheus_plugin/prometheus_plugin.cpp @@ -24,7 +24,7 @@ namespace eosio { }; prometheus_plugin::prometheus_plugin() - : my(new prometheus_plugin_impl{}) { + : my(new prometheus_plugin_impl) { } prometheus_plugin::~prometheus_plugin() = default; From 3cbf05f0ae553c3ebfc7f943abf4e786482ac5bf Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 3 Jan 2024 22:41:16 -0500 Subject: [PATCH 3/3] only run the stats timer when metrics are enabled --- plugins/net_plugin/net_plugin.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/net_plugin/net_plugin.cpp b/plugins/net_plugin/net_plugin.cpp index 4784ff63c1..984e3ce365 100644 --- a/plugins/net_plugin/net_plugin.cpp +++ b/plugins/net_plugin/net_plugin.cpp @@ -4597,7 +4597,6 @@ namespace eosio { // called from any thread void connections_manager::start_conn_timers() { start_conn_timer(connector_period, {}, timer_type::check); // this locks mutex - start_conn_timer(connector_period, {}, timer_type::stats); // this locks mutex if (update_p2p_connection_metrics) { start_conn_timer(connector_period + connector_period / 2, {}, timer_type::stats); // this locks mutex }