Stats
This commit is contained in:
parent
76e062e171
commit
a041091962
6 changed files with 112 additions and 16 deletions
|
|
@ -108,6 +108,7 @@ enum class detail
|
|||
// active_elections
|
||||
active_started,
|
||||
active_stopped,
|
||||
active_cemented,
|
||||
|
||||
// election
|
||||
election_confirmed,
|
||||
|
|
|
|||
|
|
@ -62,9 +62,11 @@ enum class type
|
|||
active,
|
||||
active_elections,
|
||||
active_started,
|
||||
active_stopped,
|
||||
active_confirmed,
|
||||
active_dropped,
|
||||
active_timeout,
|
||||
active_cemented,
|
||||
backlog,
|
||||
unchecked,
|
||||
election_scheduler,
|
||||
|
|
@ -378,6 +380,10 @@ enum class detail
|
|||
insert,
|
||||
insert_failed,
|
||||
|
||||
// active_elections
|
||||
started,
|
||||
stopped,
|
||||
|
||||
// unchecked
|
||||
put,
|
||||
satisfied,
|
||||
|
|
@ -447,7 +453,19 @@ enum class detail
|
|||
|
||||
// confirming_set
|
||||
notify_cemented,
|
||||
notify_already_confirmed,
|
||||
notify_already_cemented,
|
||||
|
||||
// election_state
|
||||
passive,
|
||||
active,
|
||||
expired_confirmed,
|
||||
expired_unconfirmed,
|
||||
|
||||
// election_status_type
|
||||
ongoing,
|
||||
active_confirmed_quorum,
|
||||
active_confirmation_height,
|
||||
inactive_confirmation_height,
|
||||
|
||||
_last // Must be the last enum
|
||||
};
|
||||
|
|
|
|||
|
|
@ -120,7 +120,13 @@ void nano::active_elections::block_cemented_callback (nano::secure::transaction
|
|||
}
|
||||
recently_cemented.put (status);
|
||||
|
||||
node.stats.inc (nano::stat::type::active_elections, nano::stat::detail::cemented);
|
||||
node.stats.inc (nano::stat::type::active_cemented, to_stat_detail (status.type));
|
||||
|
||||
node.logger.trace (nano::log::type::active_elections, nano::log::detail::active_cemented, nano::log::arg{ "election", election });
|
||||
|
||||
notify_observers (transaction, status, votes);
|
||||
|
||||
bool cemented_bootstrap_count_reached = node.ledger.cemented_count () >= node.ledger.bootstrap_weight_max_blocks;
|
||||
bool was_active = status.type == nano::election_status_type::active_confirmed_quorum || status.type == nano::election_status_type::active_confirmation_height;
|
||||
|
||||
|
|
@ -302,7 +308,10 @@ void nano::active_elections::cleanup_election (nano::unique_lock<nano::mutex> &
|
|||
|
||||
roots.get<tag_root> ().erase (roots.get<tag_root> ().find (election->qualified_root));
|
||||
|
||||
node.stats.inc (completion_type (*election), to_stat_detail (election->behavior ()));
|
||||
node.stats.inc (nano::stat::type::active_elections, nano::stat::detail::stopped);
|
||||
node.stats.inc (nano::stat::type::active_stopped, to_stat_detail (election->state ()));
|
||||
node.stats.inc (to_stat_type (election->state ()), to_stat_detail (election->behavior ()));
|
||||
|
||||
node.logger.trace (nano::log::type::active_elections, nano::log::detail::active_stopped, nano::log::arg{ "election", election });
|
||||
|
||||
node.logger.debug (nano::log::type::active_elections, "Erased election for blocks: {} (behavior: {}, state: {})",
|
||||
|
|
@ -332,19 +341,6 @@ void nano::active_elections::cleanup_election (nano::unique_lock<nano::mutex> &
|
|||
}
|
||||
}
|
||||
|
||||
nano::stat::type nano::active_elections::completion_type (nano::election const & election) const
|
||||
{
|
||||
if (election.confirmed ())
|
||||
{
|
||||
return nano::stat::type::active_confirmed;
|
||||
}
|
||||
if (election.failed ())
|
||||
{
|
||||
return nano::stat::type::active_timeout;
|
||||
}
|
||||
return nano::stat::type::active_dropped;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<nano::election>> nano::active_elections::list_active (std::size_t max_a)
|
||||
{
|
||||
nano::lock_guard<nano::mutex> guard{ mutex };
|
||||
|
|
@ -421,7 +417,9 @@ nano::election_insertion_result nano::active_elections::insert (std::shared_ptr<
|
|||
debug_assert (count_by_behavior[result.election->behavior ()] >= 0);
|
||||
count_by_behavior[result.election->behavior ()]++;
|
||||
|
||||
node.stats.inc (nano::stat::type::active_elections, nano::stat::detail::started);
|
||||
node.stats.inc (nano::stat::type::active_started, to_stat_detail (election_behavior_a));
|
||||
|
||||
node.logger.trace (nano::log::type::active_elections, nano::log::detail::active_started,
|
||||
nano::log::arg{ "behavior", election_behavior_a },
|
||||
nano::log::arg{ "election", result.election });
|
||||
|
|
@ -598,3 +596,75 @@ nano::error nano::active_elections_config::deserialize (nano::tomlconfig & toml)
|
|||
|
||||
return toml.get_error ();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
nano::stat::type nano::to_stat_type (nano::election_state state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case election_state::passive:
|
||||
case election_state::active:
|
||||
return nano::stat::type::active_dropped;
|
||||
break;
|
||||
case election_state::confirmed:
|
||||
case election_state::expired_confirmed:
|
||||
return nano::stat::type::active_confirmed;
|
||||
break;
|
||||
case election_state::expired_unconfirmed:
|
||||
return nano::stat::type::active_timeout;
|
||||
break;
|
||||
}
|
||||
debug_assert (false);
|
||||
return {};
|
||||
}
|
||||
|
||||
nano::stat::detail nano::to_stat_detail (nano::election_state state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case election_state::passive:
|
||||
return nano::stat::detail::passive;
|
||||
break;
|
||||
case election_state::active:
|
||||
return nano::stat::detail::active;
|
||||
break;
|
||||
case election_state::confirmed:
|
||||
return nano::stat::detail::confirmed;
|
||||
break;
|
||||
case election_state::expired_confirmed:
|
||||
return nano::stat::detail::expired_confirmed;
|
||||
break;
|
||||
case election_state::expired_unconfirmed:
|
||||
return nano::stat::detail::expired_unconfirmed;
|
||||
break;
|
||||
}
|
||||
debug_assert (false);
|
||||
return {};
|
||||
}
|
||||
|
||||
nano::stat::detail nano::to_stat_detail (nano::election_status_type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case election_status_type::ongoing:
|
||||
return nano::stat::detail::ongoing;
|
||||
break;
|
||||
case election_status_type::active_confirmed_quorum:
|
||||
return nano::stat::detail::active_confirmed_quorum;
|
||||
break;
|
||||
case election_status_type::active_confirmation_height:
|
||||
return nano::stat::detail::active_confirmation_height;
|
||||
break;
|
||||
case election_status_type::inactive_confirmation_height:
|
||||
return nano::stat::detail::inactive_confirmation_height;
|
||||
break;
|
||||
case election_status_type::stopped:
|
||||
return nano::stat::detail::stopped;
|
||||
break;
|
||||
}
|
||||
debug_assert (false);
|
||||
return {};
|
||||
}
|
||||
|
|
@ -36,6 +36,7 @@ class confirming_set;
|
|||
class election;
|
||||
class vote;
|
||||
class stats;
|
||||
enum class election_state;
|
||||
}
|
||||
namespace nano::secure
|
||||
{
|
||||
|
|
@ -197,4 +198,7 @@ public: // Tests
|
|||
};
|
||||
|
||||
std::unique_ptr<container_info_component> collect_container_info (active_elections & active_elections, std::string const & name);
|
||||
|
||||
nano::stat::type to_stat_type (nano::election_state);
|
||||
nano::stat::detail to_stat_detail (nano::election_state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ nano::confirming_set::confirming_set (nano::ledger & ledger_a, nano::stats & sta
|
|||
}
|
||||
for (auto const & i : notification.already_cemented)
|
||||
{
|
||||
stats.inc (nano::stat::type::confirming_set, nano::stat::detail::notify_already_confirmed);
|
||||
stats.inc (nano::stat::type::confirming_set, nano::stat::detail::notify_already_cemented);
|
||||
block_already_cemented_observers.notify (i);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/lib/numbers.hpp>
|
||||
#include <nano/lib/stats_enums.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
|
@ -22,6 +23,8 @@ enum class election_status_type : uint8_t
|
|||
stopped = 5
|
||||
};
|
||||
|
||||
nano::stat::detail to_stat_detail (election_status_type);
|
||||
|
||||
/* Holds a summary of an election */
|
||||
class election_status final
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue