Stats
This commit is contained in:
parent
b7d782f3a8
commit
5e47b802b3
3 changed files with 37 additions and 11 deletions
|
|
@ -26,7 +26,9 @@ enum class type
|
||||||
election,
|
election,
|
||||||
election_cleanup,
|
election_cleanup,
|
||||||
election_vote,
|
election_vote,
|
||||||
http_callback,
|
http_callbacks,
|
||||||
|
http_callbacks_notified,
|
||||||
|
http_callbacks_ec,
|
||||||
ipc,
|
ipc,
|
||||||
tcp,
|
tcp,
|
||||||
tcp_server,
|
tcp_server,
|
||||||
|
|
@ -166,6 +168,8 @@ enum class detail
|
||||||
other,
|
other,
|
||||||
drop,
|
drop,
|
||||||
queued,
|
queued,
|
||||||
|
error,
|
||||||
|
failed,
|
||||||
|
|
||||||
// processing queue
|
// processing queue
|
||||||
queue,
|
queue,
|
||||||
|
|
@ -625,6 +629,16 @@ enum class detail
|
||||||
host_unreachable,
|
host_unreachable,
|
||||||
not_supported,
|
not_supported,
|
||||||
|
|
||||||
|
// http
|
||||||
|
error_resolving,
|
||||||
|
error_connecting,
|
||||||
|
error_sending,
|
||||||
|
error_completing,
|
||||||
|
bad_status,
|
||||||
|
|
||||||
|
// http_callbacks
|
||||||
|
block_confirmed,
|
||||||
|
|
||||||
_last // Must be the last enum
|
_last // Must be the last enum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ void nano::http_callbacks::setup_callbacks ()
|
||||||
// Only process blocks that have achieved quorum or confirmation height
|
// Only process blocks that have achieved quorum or confirmation height
|
||||||
if ((status_a.type == nano::election_status_type::active_confirmed_quorum || status_a.type == nano::election_status_type::active_confirmation_height))
|
if ((status_a.type == nano::election_status_type::active_confirmed_quorum || status_a.type == nano::election_status_type::active_confirmation_height))
|
||||||
{
|
{
|
||||||
|
stats.inc (nano::stat::type::http_callbacks_notified, nano::stat::detail::block_confirmed);
|
||||||
|
|
||||||
// Post callback processing to worker thread
|
// Post callback processing to worker thread
|
||||||
// Safe to capture 'this' by reference as workers are stopped before node destruction
|
// Safe to capture 'this' by reference as workers are stopped before node destruction
|
||||||
node.workers.post ([this, block_a, account_a, amount_a, is_state_send_a, is_state_epoch_a] () {
|
node.workers.post ([this, block_a, account_a, amount_a, is_state_send_a, is_state_epoch_a] () {
|
||||||
|
|
@ -93,8 +95,10 @@ void nano::http_callbacks::setup_callbacks ()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
stats.inc (nano::stat::type::http_callbacks, nano::stat::detail::error_resolving);
|
||||||
|
stats.inc (nano::stat::type::http_callbacks_ec, to_stat_detail (ec));
|
||||||
|
|
||||||
logger.error (nano::log::type::http_callbacks, "Error resolving callback: {}:{} ({})", address, port, ec.message ());
|
logger.error (nano::log::type::http_callbacks, "Error resolving callback: {}:{} ({})", address, port, ec.message ());
|
||||||
stats.inc (nano::stat::type::error, nano::stat::detail::http_callback, nano::stat::dir::out);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -117,6 +121,8 @@ std::shared_ptr<boost::asio::ip::tcp::resolver> const & resolver)
|
||||||
// Check if we have more endpoints to try
|
// Check if we have more endpoints to try
|
||||||
if (i_a != boost::asio::ip::tcp::resolver::iterator{})
|
if (i_a != boost::asio::ip::tcp::resolver::iterator{})
|
||||||
{
|
{
|
||||||
|
stats.inc (nano::stat::type::http_callbacks, nano::stat::detail::initiate);
|
||||||
|
|
||||||
// Create socket and attempt connection
|
// Create socket and attempt connection
|
||||||
auto sock = std::make_shared<boost::asio::ip::tcp::socket> (node.io_ctx);
|
auto sock = std::make_shared<boost::asio::ip::tcp::socket> (node.io_ctx);
|
||||||
sock->async_connect (i_a->endpoint (),
|
sock->async_connect (i_a->endpoint (),
|
||||||
|
|
@ -152,36 +158,42 @@ std::shared_ptr<boost::asio::ip::tcp::resolver> const & resolver)
|
||||||
// Check response status
|
// Check response status
|
||||||
if (boost::beast::http::to_status_class (resp->result ()) == boost::beast::http::status_class::successful)
|
if (boost::beast::http::to_status_class (resp->result ()) == boost::beast::http::status_class::successful)
|
||||||
{
|
{
|
||||||
stats.inc (nano::stat::type::http_callback, nano::stat::detail::initiate, nano::stat::dir::out);
|
stats.inc (nano::stat::type::http_callbacks, nano::stat::detail::success);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
stats.inc (nano::stat::type::http_callbacks, nano::stat::detail::bad_status);
|
||||||
|
|
||||||
logger.error (nano::log::type::http_callbacks, "Callback to {}:{} failed [status: {}]",
|
logger.error (nano::log::type::http_callbacks, "Callback to {}:{} failed [status: {}]",
|
||||||
address, port, nano::util::to_str (resp->result ()));
|
address, port, nano::util::to_str (resp->result ()));
|
||||||
stats.inc (nano::stat::type::error, nano::stat::detail::http_callback, nano::stat::dir::out);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
stats.inc (nano::stat::type::http_callbacks, nano::stat::detail::error_completing);
|
||||||
|
stats.inc (nano::stat::type::http_callbacks_ec, to_stat_detail (ec));
|
||||||
|
|
||||||
logger.error (nano::log::type::http_callbacks, "Unable to complete callback: {}:{} ({})",
|
logger.error (nano::log::type::http_callbacks, "Unable to complete callback: {}:{} ({})",
|
||||||
address, port, ec.message ());
|
address, port, ec.message ());
|
||||||
stats.inc (nano::stat::type::error, nano::stat::detail::http_callback, nano::stat::dir::out);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
stats.inc (nano::stat::type::http_callbacks, nano::stat::detail::error_sending);
|
||||||
|
stats.inc (nano::stat::type::http_callbacks_ec, to_stat_detail (ec));
|
||||||
|
|
||||||
logger.error (nano::log::type::http_callbacks, "Unable to send callback: {}:{} ({})", address, port, ec.message ());
|
logger.error (nano::log::type::http_callbacks, "Unable to send callback: {}:{} ({})", address, port, ec.message ());
|
||||||
stats.inc (nano::stat::type::error, nano::stat::detail::http_callback, nano::stat::dir::out);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else // Connection failed, try next endpoint if available
|
||||||
{
|
{
|
||||||
// Connection failed, try next endpoint if available
|
stats.inc (nano::stat::type::http_callbacks, nano::stat::detail::error_connecting);
|
||||||
|
stats.inc (nano::stat::type::http_callbacks_ec, to_stat_detail (ec));
|
||||||
|
|
||||||
logger.error (nano::log::type::http_callbacks, "Unable to connect to callback address({}): {}:{} ({})",
|
logger.error (nano::log::type::http_callbacks, "Unable to connect to callback address({}): {}:{} ({})",
|
||||||
address, i_a->endpoint ().address ().to_string (), port, ec.message ());
|
address, i_a->endpoint ().address ().to_string (), port, ec.message ());
|
||||||
stats.inc (nano::stat::type::error, nano::stat::detail::http_callback, nano::stat::dir::out);
|
|
||||||
|
|
||||||
++i_a;
|
++i_a;
|
||||||
do_rpc_callback (i_a, address, port, target, body, resolver);
|
do_rpc_callback (i_a, address, port, target, body, resolver);
|
||||||
|
|
|
||||||
|
|
@ -5252,7 +5252,7 @@ TEST (rpc, block_confirm_confirmed)
|
||||||
auto transaction = node->ledger.tx_begin_read ();
|
auto transaction = node->ledger.tx_begin_read ();
|
||||||
ASSERT_TRUE (node->ledger.confirmed.block_exists_or_pruned (transaction, nano::dev::genesis->hash ()));
|
ASSERT_TRUE (node->ledger.confirmed.block_exists_or_pruned (transaction, nano::dev::genesis->hash ()));
|
||||||
}
|
}
|
||||||
ASSERT_EQ (0, node->stats.count (nano::stat::type::error, nano::stat::detail::http_callback, nano::stat::dir::out));
|
ASSERT_EQ (0, node->stats.count (nano::stat::type::http_callbacks_ec));
|
||||||
auto const rpc_ctx = add_rpc (system, node);
|
auto const rpc_ctx = add_rpc (system, node);
|
||||||
boost::property_tree::ptree request;
|
boost::property_tree::ptree request;
|
||||||
request.put ("action", "block_confirm");
|
request.put ("action", "block_confirm");
|
||||||
|
|
@ -5266,7 +5266,7 @@ TEST (rpc, block_confirm_confirmed)
|
||||||
// Check callback
|
// Check callback
|
||||||
// Callback result is error because callback target port isn't listening
|
// Callback result is error because callback target port isn't listening
|
||||||
// Check for error count greater than zero as the address goes through DNS resolution and may make multiple attempts for multiple IPs per DNS
|
// Check for error count greater than zero as the address goes through DNS resolution and may make multiple attempts for multiple IPs per DNS
|
||||||
ASSERT_TIMELY (5s, node->stats.count (nano::stat::type::error, nano::stat::detail::http_callback, nano::stat::dir::out) != 0);
|
ASSERT_TIMELY (5s, node->stats.count (nano::stat::type::http_callbacks_ec) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST (rpc, node_id)
|
TEST (rpc, node_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue