Skip to content

Commit

Permalink
kagome_parachain_approvals_no_shows_total (#2168)
Browse files Browse the repository at this point in the history
Signed-off-by: turuslan <[email protected]>
  • Loading branch information
turuslan authored Aug 2, 2024
1 parent 95201a8 commit 2198335
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 15 additions & 1 deletion core/parachain/approval/approval_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ namespace {
} // namespace

namespace kagome::parachain {
constexpr auto kMetricNoShowsTotal =
"kagome_parachain_approvals_no_shows_total";

ApprovalDistribution::ApprovalDistribution(
std::shared_ptr<consensus::babe::BabeConfigRepository> babe_config_repo,
Expand Down Expand Up @@ -598,7 +600,8 @@ namespace kagome::parachain {
scheduler_{std::make_shared<libp2p::basic::SchedulerImpl>(
std::make_shared<libp2p::basic::AsioSchedulerBackend>(
approval_thread_pool.io_context()),
libp2p::basic::Scheduler::Config{})} {
libp2p::basic::Scheduler::Config{})},
metrics_registry_{metrics::createRegistry()} {
BOOST_ASSERT(parachain_host_);
BOOST_ASSERT(keystore_);
BOOST_ASSERT(peer_view_);
Expand All @@ -614,6 +617,12 @@ namespace kagome::parachain {
BOOST_ASSERT(main_pool_handler_);
BOOST_ASSERT(worker_pool_handler_);
BOOST_ASSERT(approval_thread_handler_);

metrics_registry_->registerCounterFamily(
kMetricNoShowsTotal,
"Number of assignments which became no-shows in the approval voting subsystem");
metric_no_shows_total_ =
metrics_registry_->registerCounterMetric(kMetricNoShowsTotal);
}

bool ApprovalDistribution::tryStart() {
Expand Down Expand Up @@ -2996,6 +3005,11 @@ namespace kagome::parachain {
block_entry.mark_approved_by_hash(candidate_hash);
const auto is_block_approved = block_entry.is_fully_approved();

auto no_shows = known_no_shows(check);
if (no_shows != 0) {
metric_no_shows_total_->inc(no_shows);
}

if (is_block_approved && !was_block_approved) {
notifyApproved(block_hash);
}
Expand Down
3 changes: 3 additions & 0 deletions core/parachain/approval/approval_distribution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,9 @@ namespace kagome::parachain {
};
SafeObject<std::unordered_map<CandidateHash, ApprovalCache>, std::mutex>
approvals_cache_;

metrics::RegistryPtr metrics_registry_;
metrics::Counter *metric_no_shows_total_;
};

} // namespace kagome::parachain

0 comments on commit 2198335

Please sign in to comment.