Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Add a metric for partitioned disputes
Browse files Browse the repository at this point in the history
  • Loading branch information
tdimitrov committed May 31, 2022
1 parent 8aa99c1 commit bf8affe
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion node/core/provisioner/src/disputes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ where
);

let partitioned = partition_recent_disputes(recent_disputes, &onchain);
metrics.on_partition_recent_disputes(&partitioned);
gum::trace!(target: LOG_TARGET, ?leaf, "ACTIVE disputes after partitioning: without enough votes to conclude onchain: {}; unknown onchain: {}; with enough votes to conclude onchain: {};", partitioned.cant_conclude_onchain.len(), partitioned.unknown_onchain.len(), partitioned.can_conclude_onchain.len());
gum::trace!(target: LOG_TARGET, ?leaf, "CONCLUDED disputes after partitioning: concluded_known_onchain (will be dropped): {}; concluded_unknown_onchain: {}", partitioned.concluded_known_onchain.len() , partitioned.concluded_unknown_onchain.len());

Expand Down Expand Up @@ -130,7 +131,7 @@ where
result
}

struct PartitionedDisputes {
pub(crate) struct PartitionedDisputes {
// Active disputes without enough onchain votes to conclude. These
// will be sent to the Runtime with FIRST priority.
pub cant_conclude_onchain: Vec<(SessionIndex, CandidateHash)>,
Expand Down
53 changes: 53 additions & 0 deletions node/core/provisioner/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use crate::disputes::PartitionedDisputes;
use polkadot_node_subsystem_util::metrics::{self, prometheus};

#[derive(Clone)]
Expand All @@ -28,6 +29,9 @@ struct MetricsInner {
/// 4 hours on Polkadot. The metrics are updated only when the node authors a block, so values vary across nodes.
inherent_data_dispute_statement_sets: prometheus::Counter<prometheus::U64>,
inherent_data_dispute_statements: prometheus::CounterVec<prometheus::U64>,

// The disputes received from `disputes-coordinator` by partition
partitioned_disputes: prometheus::CounterVec<prometheus::U64>,
}

/// Provisioner metrics.
Expand Down Expand Up @@ -95,6 +99,39 @@ impl Metrics {
.inc_by(disputes.try_into().unwrap_or(0));
}
}

pub(crate) fn on_partition_recent_disputes(&self, disputes: &PartitionedDisputes) {
if let Some(metrics) = &self.0 {
let PartitionedDisputes {
cant_conclude_onchain,
unknown_onchain,
can_conclude_onchain,
concluded_known_onchain,
concluded_unknown_onchain,
} = disputes;

metrics
.partitioned_disputes
.with_label_values(&["cant_conclude_onchain"])
.inc_by(cant_conclude_onchain.len() as u64);
metrics
.partitioned_disputes
.with_label_values(&["unknown_onchain"])
.inc_by(unknown_onchain.len() as u64);
metrics
.partitioned_disputes
.with_label_values(&["can_conclude_onchain"])
.inc_by(can_conclude_onchain.len() as u64);
metrics
.partitioned_disputes
.with_label_values(&["concluded_known_onchain"])
.inc_by(concluded_known_onchain.len() as u64);
metrics
.partitioned_disputes
.with_label_values(&["unknown_onchain"])
.inc_by(concluded_unknown_onchain.len() as u64);
}
}
}

impl metrics::Metrics for Metrics {
Expand Down Expand Up @@ -150,6 +187,22 @@ impl metrics::Metrics for Metrics {
)?,
registry,
)?,
partitioned_disputes: prometheus::register(
prometheus::CounterVec::new(
prometheus::Opts::new(
"polkadot_parachain_inherent_data_requests_total",
"Number of InherentData requests served by provisioner.",
),
&[
"cant_conclude_onchain",
"unknown_onchain",
"can_conclude_onchain",
"concluded_known_onchain",
"concluded_unknown_onchain",
],
)?,
registry,
)?,
};
Ok(Metrics(Some(metrics)))
}
Expand Down

0 comments on commit bf8affe

Please sign in to comment.