From fae91bd77cd7731ac95d550abc35c5c67db38763 Mon Sep 17 00:00:00 2001 From: cryptocode <34946442+cryptocode@users.noreply.github.com> Date: Fri, 24 Aug 2018 22:38:59 +0200 Subject: [PATCH] Add callback stats (#1071) --- rai/node/node.cpp | 6 ++++++ rai/node/stats.cpp | 6 ++++++ rai/node/stats.hpp | 8 ++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/rai/node/node.cpp b/rai/node/node.cpp index 2fa3b6ea..e84a9eda 100644 --- a/rai/node/node.cpp +++ b/rai/node/node.cpp @@ -1747,6 +1747,7 @@ stats (config.stat_config) { if (resp->result () == boost::beast::http::status::ok) { + node_l->stats.inc (rai::stat::type::http_callback, rai::stat::detail::initiate, rai::stat::dir::out); } else { @@ -1754,6 +1755,7 @@ stats (config.stat_config) { BOOST_LOG (node_l->log) << boost::str (boost::format ("Callback to %1%:%2% failed with status: %3%") % address % port % resp->result ()); } + node_l->stats.inc (rai::stat::type::error, rai::stat::detail::http_callback, rai::stat::dir::out); } } else @@ -1762,6 +1764,7 @@ stats (config.stat_config) { BOOST_LOG (node_l->log) << boost::str (boost::format ("Unable complete callback: %1%:%2%: %3%") % address % port % ec.message ()); } + node_l->stats.inc (rai::stat::type::error, rai::stat::detail::http_callback, rai::stat::dir::out); }; }); } @@ -1771,6 +1774,7 @@ stats (config.stat_config) { BOOST_LOG (node_l->log) << boost::str (boost::format ("Unable to send callback: %1%:%2%: %3%") % address % port % ec.message ()); } + node_l->stats.inc (rai::stat::type::error, rai::stat::detail::http_callback, rai::stat::dir::out); } }); } @@ -1780,6 +1784,7 @@ stats (config.stat_config) { BOOST_LOG (node_l->log) << boost::str (boost::format ("Unable to connect to callback address: %1%:%2%: %3%") % address % port % ec.message ()); } + node_l->stats.inc (rai::stat::type::error, rai::stat::detail::http_callback, rai::stat::dir::out); } }); } @@ -1790,6 +1795,7 @@ stats (config.stat_config) { BOOST_LOG (node_l->log) << boost::str (boost::format ("Error resolving callback: %1%:%2%: %3%") % address % port % ec.message ()); } + node_l->stats.inc (rai::stat::type::error, rai::stat::detail::http_callback, rai::stat::dir::out); } }); } diff --git a/rai/node/stats.cpp b/rai/node/stats.cpp index 4b4bd232..e6005fd4 100644 --- a/rai/node/stats.cpp +++ b/rai/node/stats.cpp @@ -324,6 +324,9 @@ std::string rai::stat::type_to_string (uint32_t key) case rai::stat::type::error: res = "error"; break; + case rai::stat::type::http_callback: + res = "http_callback"; + break; case rai::stat::type::ledger: res = "ledger"; break; @@ -388,6 +391,9 @@ std::string rai::stat::detail_to_string (uint32_t key) case rai::stat::detail::handshake: res = "handshake"; break; + case rai::stat::detail::http_callback: + res = "http_callback"; + break; case rai::stat::detail::initiate: res = "initiate"; break; diff --git a/rai/node/stats.hpp b/rai/node/stats.hpp index 1965d2e5..c3d04f05 100644 --- a/rai/node/stats.hpp +++ b/rai/node/stats.hpp @@ -183,7 +183,8 @@ public: rollback, bootstrap, vote, - peering + http_callback, + peering, }; /** Optional detail type */ @@ -194,6 +195,7 @@ public: // error specific bad_sender, insufficient_work, + http_callback, // ledger, block, bootstrap send, @@ -211,8 +213,10 @@ public: confirm_ack, node_id_handshake, - // bootstrap specific + // bootstrap, callback initiate, + + // bootstrap specific bulk_pull, bulk_push, bulk_pull_account,