mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 03:17:56 +00:00
Add Provisioner dispute metrics (#4352)
* Metrics for InherentDataProvider Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Integrate metrics Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * more changes Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fmt Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * avoid naming confusion Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Move to Provisioner. Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Add metric documentation Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -109,9 +109,9 @@ impl ParachainsInherentDataProvider {
|
||||
impl sp_inherents::InherentDataProvider for ParachainsInherentDataProvider {
|
||||
fn provide_inherent_data(
|
||||
&self,
|
||||
inherent_data: &mut sp_inherents::InherentData,
|
||||
dst_inherent_data: &mut sp_inherents::InherentData,
|
||||
) -> Result<(), sp_inherents::Error> {
|
||||
inherent_data
|
||||
dst_inherent_data
|
||||
.put_data(polkadot_primitives::v1::PARACHAINS_INHERENT_IDENTIFIER, &self.inherent_data)
|
||||
}
|
||||
|
||||
|
||||
@@ -213,6 +213,7 @@ impl ProvisioningJob {
|
||||
self.backed_candidates.clone(),
|
||||
return_senders,
|
||||
sender,
|
||||
&self.metrics,
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -254,11 +255,12 @@ async fn send_inherent_data(
|
||||
candidate_receipts: Vec<CandidateReceipt>,
|
||||
return_senders: Vec<oneshot::Sender<ProvisionerInherentData>>,
|
||||
from_job: &mut impl SubsystemSender,
|
||||
metrics: &Metrics,
|
||||
) -> Result<(), Error> {
|
||||
let backed_candidates =
|
||||
collect_backed_candidates(candidate_receipts, relay_parent, from_job).await?;
|
||||
|
||||
let disputes = collect_disputes(from_job).await?;
|
||||
let disputes = collect_disputes(from_job, metrics).await?;
|
||||
|
||||
let inherent_data = ProvisionerInherentData { bitfields, backed_candidates, disputes };
|
||||
|
||||
@@ -324,6 +326,7 @@ async fn collect_backed_candidates(
|
||||
|
||||
async fn collect_disputes(
|
||||
sender: &mut impl SubsystemSender,
|
||||
metrics: &metrics::Metrics,
|
||||
) -> Result<MultiDisputeStatementSet, Error> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
@@ -385,6 +388,10 @@ async fn collect_disputes(
|
||||
.into_iter()
|
||||
.map(|(s, i, sig)| (DisputeStatement::Invalid(s), i, sig));
|
||||
|
||||
metrics.inc_valid_statements_by(valid_statements.len());
|
||||
metrics.inc_invalid_statements_by(invalid_statements.len());
|
||||
metrics.inc_dispute_statement_sets_by(1);
|
||||
|
||||
DisputeStatementSet {
|
||||
candidate_hash,
|
||||
session: session_index,
|
||||
|
||||
@@ -15,12 +15,19 @@
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use polkadot_node_subsystem_util::metrics::{self, prometheus};
|
||||
use std::convert::TryInto;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct MetricsInner {
|
||||
inherent_data_requests: prometheus::CounterVec<prometheus::U64>,
|
||||
request_inherent_data: prometheus::Histogram,
|
||||
provisionable_data: prometheus::Histogram,
|
||||
|
||||
/// The dispute_statement.* metrics trak how many disputes/votes the runtime will have to process. It will count
|
||||
/// all recent statements meaning every dispute from last sessions: 10 min on Rococo, 60 min on Kusama and
|
||||
/// 4 hours on Polkadot. The metrics are updated only when the node authors block, so values vary across nodes.
|
||||
dispute_statement_sets_requested: prometheus::Counter<prometheus::U64>,
|
||||
dispute_statements_requested: prometheus::CounterVec<prometheus::U64>,
|
||||
}
|
||||
|
||||
/// Provisioner metrics.
|
||||
@@ -50,6 +57,32 @@ impl Metrics {
|
||||
) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
||||
self.0.as_ref().map(|metrics| metrics.provisionable_data.start_timer())
|
||||
}
|
||||
|
||||
pub(crate) fn inc_valid_statements_by(&self, votes: usize) {
|
||||
if let Some(metrics) = &self.0 {
|
||||
metrics
|
||||
.dispute_statements_requested
|
||||
.with_label_values(&["valid"])
|
||||
.inc_by(votes.try_into().unwrap_or(0));
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn inc_invalid_statements_by(&self, votes: usize) {
|
||||
if let Some(metrics) = &self.0 {
|
||||
metrics
|
||||
.dispute_statements_requested
|
||||
.with_label_values(&["invalid"])
|
||||
.inc_by(votes.try_into().unwrap_or(0));
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn inc_dispute_statement_sets_by(&self, disputes: usize) {
|
||||
if let Some(metrics) = &self.0 {
|
||||
metrics
|
||||
.dispute_statement_sets_requested
|
||||
.inc_by(disputes.try_into().unwrap_or(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl metrics::Metrics for Metrics {
|
||||
@@ -79,6 +112,23 @@ impl metrics::Metrics for Metrics {
|
||||
))?,
|
||||
registry,
|
||||
)?,
|
||||
dispute_statements_requested: prometheus::register(
|
||||
prometheus::CounterVec::new(
|
||||
prometheus::Opts::new(
|
||||
"parachain_inherent_dispute_statements_requested",
|
||||
"Number of inherent dispute statements requested.",
|
||||
),
|
||||
&["validity"],
|
||||
)?,
|
||||
®istry,
|
||||
)?,
|
||||
dispute_statement_sets_requested: prometheus::register(
|
||||
prometheus::Counter::new(
|
||||
"parachain_inherent_dispute_statement_sets_requested",
|
||||
"Number of inherent DisputeStatementSets requested.",
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
};
|
||||
Ok(Metrics(Some(metrics)))
|
||||
}
|
||||
|
||||
@@ -1015,6 +1015,7 @@ where
|
||||
create_inherent_data_providers: move |parent, ()| {
|
||||
let client_clone = client_clone.clone();
|
||||
let overseer_handle = overseer_handle.clone();
|
||||
|
||||
async move {
|
||||
let parachain = polkadot_node_core_parachains_inherent::ParachainsInherentDataProvider::create(
|
||||
&*client_clone,
|
||||
|
||||
Reference in New Issue
Block a user