mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 15:41:02 +00:00
Parachain runtime metrics followup (#4602)
* initial changes Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fmt Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * remove file Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Remove pallet Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix copyright year Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Remove metric registration op Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Register runtime metrics in client Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fmt Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix build without `runtime-metrics` Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * reduce visibility Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * remove metric prefix logic, use hardcoded Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * review feedback Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Split CounterVec api so it doesn't need mutability Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Const beautify Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Fix Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix docs Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Merge web ui feedback. Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -35,7 +35,7 @@ pub mod runtime;
|
|||||||
#[cfg(feature = "runtime-metrics")]
|
#[cfg(feature = "runtime-metrics")]
|
||||||
pub use self::runtime::logger_hook;
|
pub use self::runtime::logger_hook;
|
||||||
|
|
||||||
/// Export a dummy logger hook when `wasm tracing` is not enabled.
|
/// Export a dummy logger hook when the `runtime-metrics` feature is not enabled.
|
||||||
#[cfg(not(feature = "runtime-metrics"))]
|
#[cfg(not(feature = "runtime-metrics"))]
|
||||||
pub fn logger_hook() -> impl FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration) -> () {
|
pub fn logger_hook() -> impl FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration) -> () {
|
||||||
|_logger_builder, _config| {}
|
|_logger_builder, _config| {}
|
||||||
|
|||||||
@@ -20,11 +20,13 @@
|
|||||||
//! tracing support. This requires that the custom profiler (`TraceHandler`) to be
|
//! tracing support. This requires that the custom profiler (`TraceHandler`) to be
|
||||||
//! registered in substrate via a `logger_hook()`. Events emitted from runtime are
|
//! registered in substrate via a `logger_hook()`. Events emitted from runtime are
|
||||||
//! then captured/processed by the `TraceHandler` implementation.
|
//! then captured/processed by the `TraceHandler` implementation.
|
||||||
|
|
||||||
#![cfg(feature = "runtime-metrics")]
|
#![cfg(feature = "runtime-metrics")]
|
||||||
|
|
||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
use primitives::v1::{
|
use primitives::v1::{
|
||||||
RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricRegisterParams, RuntimeMetricUpdate,
|
metric_definitions::{CounterDefinition, CounterVecDefinition},
|
||||||
|
RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricUpdate,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
collections::hash_map::HashMap,
|
collections::hash_map::HashMap,
|
||||||
@@ -33,9 +35,9 @@ use std::{
|
|||||||
use substrate_prometheus_endpoint::{
|
use substrate_prometheus_endpoint::{
|
||||||
register, Counter, CounterVec, Opts, PrometheusError, Registry, U64,
|
register, Counter, CounterVec, Opts, PrometheusError, Registry, U64,
|
||||||
};
|
};
|
||||||
|
mod parachain;
|
||||||
|
|
||||||
const LOG_TARGET: &'static str = "metrics::runtime";
|
const LOG_TARGET: &'static str = "metrics::runtime";
|
||||||
const METRIC_PREFIX: &'static str = "polkadot";
|
|
||||||
|
|
||||||
/// Holds the registered Prometheus metric collections.
|
/// Holds the registered Prometheus metric collections.
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
@@ -55,12 +57,12 @@ impl RuntimeMetricsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Register a counter vec metric.
|
/// Register a counter vec metric.
|
||||||
pub fn register_countervec(&self, metric_name: &str, params: &RuntimeMetricRegisterParams) {
|
pub fn register_countervec(&self, countervec: CounterVecDefinition) {
|
||||||
self.with_counter_vecs_lock_held(|mut hashmap| {
|
self.with_counter_vecs_lock_held(|mut hashmap| {
|
||||||
hashmap.entry(metric_name.to_owned()).or_insert(register(
|
hashmap.entry(countervec.name.to_owned()).or_insert(register(
|
||||||
CounterVec::new(
|
CounterVec::new(
|
||||||
Opts::new(metric_name, params.description()),
|
Opts::new(countervec.name, countervec.description),
|
||||||
¶ms.labels().unwrap_or_default(),
|
countervec.labels,
|
||||||
)?,
|
)?,
|
||||||
&self.0,
|
&self.0,
|
||||||
)?);
|
)?);
|
||||||
@@ -69,11 +71,11 @@ impl RuntimeMetricsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Register a counter metric.
|
/// Register a counter metric.
|
||||||
pub fn register_counter(&self, metric_name: &str, params: &RuntimeMetricRegisterParams) {
|
pub fn register_counter(&self, counter: CounterDefinition) {
|
||||||
self.with_counters_lock_held(|mut hashmap| {
|
self.with_counters_lock_held(|mut hashmap| {
|
||||||
hashmap
|
hashmap
|
||||||
.entry(metric_name.to_owned())
|
.entry(counter.name.to_owned())
|
||||||
.or_insert(register(Counter::new(metric_name, params.description())?, &self.0)?);
|
.or_insert(register(Counter::new(counter.name, counter.description)?, &self.0)?);
|
||||||
return Ok(())
|
return Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -162,18 +164,11 @@ impl sc_tracing::TraceHandler for RuntimeMetricsProvider {
|
|||||||
impl RuntimeMetricsProvider {
|
impl RuntimeMetricsProvider {
|
||||||
// Parse end execute the update operation.
|
// Parse end execute the update operation.
|
||||||
fn parse_metric_update(&self, update: RuntimeMetricUpdate) {
|
fn parse_metric_update(&self, update: RuntimeMetricUpdate) {
|
||||||
let metric_name = &format!("{}_{}", METRIC_PREFIX, update.metric_name());
|
|
||||||
|
|
||||||
match update.op {
|
match update.op {
|
||||||
RuntimeMetricOp::Register(ref params) =>
|
|
||||||
if params.labels.is_none() {
|
|
||||||
self.register_counter(metric_name, ¶ms);
|
|
||||||
} else {
|
|
||||||
self.register_countervec(metric_name, ¶ms);
|
|
||||||
},
|
|
||||||
RuntimeMetricOp::IncrementCounterVec(value, ref labels) =>
|
RuntimeMetricOp::IncrementCounterVec(value, ref labels) =>
|
||||||
self.inc_counter_vec_by(metric_name, value, labels),
|
self.inc_counter_vec_by(update.metric_name(), value, labels),
|
||||||
RuntimeMetricOp::IncrementCounter(value) => self.inc_counter_by(metric_name, value),
|
RuntimeMetricOp::IncrementCounter(value) =>
|
||||||
|
self.inc_counter_by(update.metric_name(), value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,6 +200,7 @@ pub fn logger_hook() -> impl FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Con
|
|||||||
}
|
}
|
||||||
let registry = config.prometheus_registry().cloned().unwrap();
|
let registry = config.prometheus_registry().cloned().unwrap();
|
||||||
let metrics_provider = RuntimeMetricsProvider::new(registry);
|
let metrics_provider = RuntimeMetricsProvider::new(registry);
|
||||||
|
parachain::register_metrics(&metrics_provider);
|
||||||
logger_builder.with_custom_profiling(Box::new(metrics_provider));
|
logger_builder.with_custom_profiling(Box::new(metrics_provider));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Polkadot.
|
||||||
|
|
||||||
|
// Polkadot is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Polkadot is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Client side declaration and registration of the parachain Prometheus metrics.
|
||||||
|
//! All of the metrics have a correspondent runtime metric definition.
|
||||||
|
|
||||||
|
use crate::runtime::RuntimeMetricsProvider;
|
||||||
|
use primitives::v1::metric_definitions::{
|
||||||
|
PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS,
|
||||||
|
PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED, PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED,
|
||||||
|
PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED,
|
||||||
|
PARACHAIN_INHERENT_DATA_WEIGHT,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Register the parachain runtime metrics.
|
||||||
|
pub fn register_metrics(runtime_metrics_provider: &RuntimeMetricsProvider) {
|
||||||
|
runtime_metrics_provider.register_counter(PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED);
|
||||||
|
runtime_metrics_provider.register_counter(PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED);
|
||||||
|
|
||||||
|
runtime_metrics_provider.register_countervec(PARACHAIN_INHERENT_DATA_WEIGHT);
|
||||||
|
runtime_metrics_provider.register_countervec(PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED);
|
||||||
|
runtime_metrics_provider.register_countervec(PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED);
|
||||||
|
runtime_metrics_provider
|
||||||
|
.register_countervec(PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS);
|
||||||
|
}
|
||||||
@@ -19,35 +19,16 @@
|
|||||||
use parity_scale_codec::{Decode, Encode};
|
use parity_scale_codec::{Decode, Encode};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
/// Metric registration parameters.
|
|
||||||
#[derive(Encode, Decode)]
|
|
||||||
#[cfg_attr(feature = "std", derive(Debug))]
|
|
||||||
pub struct RuntimeMetricRegisterParams {
|
|
||||||
/// Metric description.
|
|
||||||
description: Vec<u8>,
|
|
||||||
/// Only for counter vec.
|
|
||||||
pub labels: Option<RuntimeMetricLabels>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Runtime metric operations.
|
/// Runtime metric operations.
|
||||||
#[derive(Encode, Decode)]
|
#[derive(Encode, Decode)]
|
||||||
#[cfg_attr(feature = "std", derive(Debug))]
|
#[cfg_attr(feature = "std", derive(Debug))]
|
||||||
pub enum RuntimeMetricOp {
|
pub enum RuntimeMetricOp {
|
||||||
/// Register a new metric.
|
|
||||||
Register(RuntimeMetricRegisterParams),
|
|
||||||
/// Increment a counter metric with labels by value.
|
/// Increment a counter metric with labels by value.
|
||||||
IncrementCounterVec(u64, RuntimeMetricLabelValues),
|
IncrementCounterVec(u64, RuntimeMetricLabelValues),
|
||||||
/// Increment a counter metric by value.
|
/// Increment a counter metric by value.
|
||||||
IncrementCounter(u64),
|
IncrementCounter(u64),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RuntimeMetricRegisterParams {
|
|
||||||
/// Create new metric registration params.
|
|
||||||
pub fn new(description: Vec<u8>, labels: Option<RuntimeMetricLabels>) -> Self {
|
|
||||||
Self { description, labels }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Runtime metric update event.
|
/// Runtime metric update event.
|
||||||
#[derive(Encode, Decode)]
|
#[derive(Encode, Decode)]
|
||||||
#[cfg_attr(feature = "std", derive(Debug))]
|
#[cfg_attr(feature = "std", derive(Debug))]
|
||||||
@@ -62,18 +43,6 @@ fn vec_to_str<'a>(v: &'a Vec<u8>, default: &'static str) -> &'a str {
|
|||||||
return sp_std::str::from_utf8(v).unwrap_or(default)
|
return sp_std::str::from_utf8(v).unwrap_or(default)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RuntimeMetricRegisterParams {
|
|
||||||
/// Returns the metric description.
|
|
||||||
pub fn description(&self) -> &str {
|
|
||||||
vec_to_str(&self.description, "No description provided.")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a label names as an `Option` of `Vec<&str>`.
|
|
||||||
pub fn labels(&self) -> Option<Vec<&str>> {
|
|
||||||
self.labels.as_ref().map(|labels| labels.as_str_vec())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RuntimeMetricLabels {
|
impl RuntimeMetricLabels {
|
||||||
/// Returns a labels as `Vec<&str>`.
|
/// Returns a labels as `Vec<&str>`.
|
||||||
pub fn as_str_vec(&self) -> Vec<&str> {
|
pub fn as_str_vec(&self) -> Vec<&str> {
|
||||||
@@ -137,3 +106,74 @@ impl From<&'static str> for RuntimeMetricLabel {
|
|||||||
Self(s.as_bytes().to_vec())
|
Self(s.as_bytes().to_vec())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Contains all runtime metrics defined as constants.
|
||||||
|
pub mod metric_definitions {
|
||||||
|
/// `Counter` metric definition.
|
||||||
|
pub struct CounterDefinition {
|
||||||
|
/// The name of the metric.
|
||||||
|
pub name: &'static str,
|
||||||
|
/// The description of the metric.
|
||||||
|
pub description: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `CounterVec` metric definition.
|
||||||
|
pub struct CounterVecDefinition<'a> {
|
||||||
|
/// The name of the metric.
|
||||||
|
pub name: &'static str,
|
||||||
|
/// The description of the metric.
|
||||||
|
pub description: &'static str,
|
||||||
|
/// The label names of the metric.
|
||||||
|
pub labels: &'a [&'static str],
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Counts parachain inherent data weights. Use `before` and `after` labels to differentiate
|
||||||
|
/// between the weight before and after filtering.
|
||||||
|
pub const PARACHAIN_INHERENT_DATA_WEIGHT: CounterVecDefinition = CounterVecDefinition {
|
||||||
|
name: "polkadot_parachain_inherent_data_weight",
|
||||||
|
description: "Inherent data weight before and after filtering",
|
||||||
|
labels: &["when"],
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Counts the number of bitfields processed in `enter_inner`.
|
||||||
|
pub const PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED: CounterDefinition = CounterDefinition {
|
||||||
|
name: "polkadot_parachain_inherent_data_bitfields_processed",
|
||||||
|
description: "Counts the number of bitfields processed in `enter_inner`.",
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Counts the `total`, `sanitized` and `included` number of parachain block candidates
|
||||||
|
/// in `enter_inner`.
|
||||||
|
pub const PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED: CounterVecDefinition =
|
||||||
|
CounterVecDefinition {
|
||||||
|
name: "polkadot_parachain_inherent_data_candidates_processed",
|
||||||
|
description:
|
||||||
|
"Counts the number of parachain block candidates processed in `enter_inner`.",
|
||||||
|
labels: &["category"],
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Counts the number of `imported`, `current` and `concluded_invalid` dispute statements sets
|
||||||
|
/// processed in `enter_inner`. The `current` label refers to the disputes statement sets of
|
||||||
|
/// the current session.
|
||||||
|
pub const PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED: CounterVecDefinition =
|
||||||
|
CounterVecDefinition {
|
||||||
|
name: "polkadot_parachain_inherent_data_dispute_sets_processed",
|
||||||
|
description: "Counts the number of dispute statements sets processed in `enter_inner`.",
|
||||||
|
labels: &["category"],
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Counts the number of dispute statements sets included in a block in `enter_inner`.
|
||||||
|
pub const PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED: CounterDefinition =
|
||||||
|
CounterDefinition {
|
||||||
|
name: "polkadot_parachain_inherent_data_dispute_sets_included",
|
||||||
|
description:
|
||||||
|
"Counts the number of dispute statements sets included in a block in `enter_inner`.",
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Counts the number of `valid` and `invalid` bitfields signature checked in `enter_inner`.
|
||||||
|
pub const PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS: CounterVecDefinition =
|
||||||
|
CounterVecDefinition {
|
||||||
|
name: "polkadot_parachain_create_inherent_bitfields_signature_checks",
|
||||||
|
description: "Counts the number of bitfields signature checked in `enter_inner`.",
|
||||||
|
labels: &["validity"],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ pub use signed::{EncodeAs, Signed, UncheckedSigned};
|
|||||||
|
|
||||||
mod metrics;
|
mod metrics;
|
||||||
pub use metrics::{
|
pub use metrics::{
|
||||||
RuntimeMetricLabel, RuntimeMetricLabelValue, RuntimeMetricLabelValues, RuntimeMetricLabels,
|
metric_definitions, RuntimeMetricLabel, RuntimeMetricLabelValue, RuntimeMetricLabelValues,
|
||||||
RuntimeMetricOp, RuntimeMetricRegisterParams, RuntimeMetricUpdate,
|
RuntimeMetricLabels, RuntimeMetricOp, RuntimeMetricUpdate,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A declarations of storage keys where an external observer can find some interesting data.
|
/// A declarations of storage keys where an external observer can find some interesting data.
|
||||||
|
|||||||
@@ -16,21 +16,24 @@
|
|||||||
|
|
||||||
//! This module provides an implementation for the runtime metrics types: `Counter`
|
//! This module provides an implementation for the runtime metrics types: `Counter`
|
||||||
//! and `CounterVec`. These types expose a Prometheus like interface and same functionality.
|
//! and `CounterVec`. These types expose a Prometheus like interface and same functionality.
|
||||||
//! Each instance of a runtime metric is mapped to a Prometheus metric on the node side.
|
//! Each instance of a runtime metric is mapped to a Prometheus metric on the client side.
|
||||||
|
//! The runtime metrics must be registered with the registry in the client, otherwise
|
||||||
|
//! they will not be published.
|
||||||
|
|
||||||
const TRACING_TARGET: &'static str = "metrics";
|
const TRACING_TARGET: &'static str = "metrics";
|
||||||
|
|
||||||
use parity_scale_codec::Encode;
|
use parity_scale_codec::Encode;
|
||||||
use primitives::v1::{
|
use primitives::v1::{
|
||||||
RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricRegisterParams, RuntimeMetricUpdate,
|
metric_definitions::{CounterDefinition, CounterVecDefinition},
|
||||||
|
RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricUpdate,
|
||||||
};
|
};
|
||||||
|
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
/// Holds a set of counters that have different values for their labels,
|
/// Holds a set of counters that have different values for their labels,
|
||||||
/// like Prometheus CounterVec.
|
/// like Prometheus CounterVec.
|
||||||
pub struct CounterVec {
|
pub struct CounterVec {
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
label_values: Option<RuntimeMetricLabelValues>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A counter metric.
|
/// A counter metric.
|
||||||
@@ -49,68 +52,57 @@ trait MetricEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MetricEmitter for CounterVec {}
|
///
|
||||||
impl MetricEmitter for Counter {}
|
pub struct LabeledMetric {
|
||||||
|
name: &'static str,
|
||||||
|
label_values: RuntimeMetricLabelValues,
|
||||||
|
}
|
||||||
|
|
||||||
impl CounterVec {
|
impl LabeledMetric {
|
||||||
/// Create a new metric with specified `name`, `description` and `labels`.
|
/// Increment the counter by `value`.
|
||||||
pub fn new(name: &'static str, description: &'static str, labels: &[&'static str]) -> Self {
|
pub fn inc_by(&self, value: u64) {
|
||||||
// Send a register metric operation to node side.
|
|
||||||
let metric_update = RuntimeMetricUpdate {
|
let metric_update = RuntimeMetricUpdate {
|
||||||
metric_name: Vec::from(name),
|
metric_name: Vec::from(self.name),
|
||||||
op: RuntimeMetricOp::Register(RuntimeMetricRegisterParams::new(
|
op: RuntimeMetricOp::IncrementCounterVec(value, self.label_values.clone()),
|
||||||
Vec::from(description),
|
|
||||||
Some(labels.into()),
|
|
||||||
)),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::emit(&metric_update);
|
Self::emit(&metric_update);
|
||||||
|
|
||||||
CounterVec { name, label_values: None }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set the label values. Must be called before each increment operation.
|
|
||||||
pub fn with_label_values(&mut self, label_values: &[&'static str]) -> &mut Self {
|
|
||||||
self.label_values = Some(label_values.into());
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Increment the counter by `value`.
|
|
||||||
pub fn inc_by(&mut self, value: u64) {
|
|
||||||
self.label_values.take().map(|label_values| {
|
|
||||||
let metric_update = RuntimeMetricUpdate {
|
|
||||||
metric_name: Vec::from(self.name),
|
|
||||||
op: RuntimeMetricOp::IncrementCounterVec(value, label_values),
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::emit(&metric_update);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Increment the counter value.
|
/// Increment the counter value.
|
||||||
pub fn inc(&mut self) {
|
pub fn inc(&self) {
|
||||||
self.inc_by(1);
|
self.inc_by(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Counter {
|
impl MetricEmitter for LabeledMetric {}
|
||||||
/// Create a new counter metric with specified `name`, `description`.
|
impl MetricEmitter for Counter {}
|
||||||
pub fn new(name: &'static str, description: &'static str) -> Self {
|
|
||||||
// Send a register metric operation to node side.
|
|
||||||
let metric_update = RuntimeMetricUpdate {
|
|
||||||
metric_name: Vec::from(name),
|
|
||||||
op: RuntimeMetricOp::Register(RuntimeMetricRegisterParams::new(
|
|
||||||
Vec::from(description),
|
|
||||||
None,
|
|
||||||
)),
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::emit(&metric_update);
|
impl CounterVec {
|
||||||
Counter { name }
|
/// Create a new counter as specified by `definition`. This metric needs to be registered
|
||||||
|
/// in the client before it can be used.
|
||||||
|
pub const fn new(definition: CounterVecDefinition) -> Self {
|
||||||
|
// No register op is emitted since the metric is supposed to be registered
|
||||||
|
// on the client by the time `inc()` is called.
|
||||||
|
CounterVec { name: definition.name }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a LabeledMetric instance that provides an interface for incrementing
|
||||||
|
/// the metric.
|
||||||
|
pub fn with_label_values(&self, label_values: &[&'static str]) -> LabeledMetric {
|
||||||
|
LabeledMetric { name: self.name, label_values: label_values.into() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Counter {
|
||||||
|
/// Create a new counter as specified by `definition`. This metric needs to be registered
|
||||||
|
/// in the client before it can be used.
|
||||||
|
pub const fn new(definition: CounterDefinition) -> Self {
|
||||||
|
Counter { name: definition.name }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Increment counter by `value`.
|
/// Increment counter by `value`.
|
||||||
pub fn inc_by(&mut self, value: u64) {
|
pub fn inc_by(&self, value: u64) {
|
||||||
let metric_update = RuntimeMetricUpdate {
|
let metric_update = RuntimeMetricUpdate {
|
||||||
metric_name: Vec::from(self.name),
|
metric_name: Vec::from(self.name),
|
||||||
op: RuntimeMetricOp::IncrementCounter(value),
|
op: RuntimeMetricOp::IncrementCounter(value),
|
||||||
@@ -120,7 +112,7 @@ impl Counter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Increment counter.
|
/// Increment counter.
|
||||||
pub fn inc(&mut self) {
|
pub fn inc(&self) {
|
||||||
self.inc_by(1);
|
self.inc_by(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
//! provide a dummy implementation for the native runtime to avoid cluttering the runtime code
|
//! provide a dummy implementation for the native runtime to avoid cluttering the runtime code
|
||||||
//! with `#[cfg(feature = "runtime-metrics")]`.
|
//! with `#[cfg(feature = "runtime-metrics")]`.
|
||||||
|
|
||||||
|
use primitives::v1::metric_definitions::{CounterDefinition, CounterVecDefinition};
|
||||||
|
|
||||||
/// A dummy Counter.
|
/// A dummy Counter.
|
||||||
pub struct Counter;
|
pub struct Counter;
|
||||||
/// A dummy CounterVec.
|
/// A dummy CounterVec.
|
||||||
@@ -26,27 +28,27 @@ pub struct CounterVec;
|
|||||||
/// Dummy implementation.
|
/// Dummy implementation.
|
||||||
impl CounterVec {
|
impl CounterVec {
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
pub fn new(_name: &'static str, _description: &'static str, _labels: &[&'static str]) -> Self {
|
pub const fn new(_definition: CounterVecDefinition) -> Self {
|
||||||
CounterVec
|
CounterVec
|
||||||
}
|
}
|
||||||
/// Sets label values, implementation is a `no op`.
|
/// Sets label values, implementation is a `no op`.
|
||||||
pub fn with_label_values(&mut self, _label_values: &[&'static str]) -> &mut Self {
|
pub fn with_label_values(&self, _label_values: &[&'static str]) -> &Self {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
/// Increment counter by value, implementation is a `no op`.
|
/// Increment counter by value, implementation is a `no op`.
|
||||||
pub fn inc_by(&mut self, _: u64) {}
|
pub fn inc_by(&self, _: u64) {}
|
||||||
/// Increment counter, implementation is a `no op`.
|
/// Increment counter, implementation is a `no op`.
|
||||||
pub fn inc(&mut self) {}
|
pub fn inc(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dummy implementation.
|
/// Dummy implementation.
|
||||||
impl Counter {
|
impl Counter {
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
pub fn new(_name: &'static str, _description: &'static str) -> Self {
|
pub const fn new(_definition: CounterDefinition) -> Self {
|
||||||
Counter
|
Counter
|
||||||
}
|
}
|
||||||
/// Increment counter by value, implementation is a `no op`.
|
/// Increment counter by value, implementation is a `no op`.
|
||||||
pub fn inc_by(&mut self, _: u64) {}
|
pub fn inc_by(&self, _: u64) {}
|
||||||
/// Increment counter, implementation is a `no op`.
|
/// Increment counter, implementation is a `no op`.
|
||||||
pub fn inc(&mut self) {}
|
pub fn inc(&self) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ pub mod dmp;
|
|||||||
pub mod hrmp;
|
pub mod hrmp;
|
||||||
pub mod inclusion;
|
pub mod inclusion;
|
||||||
pub mod initializer;
|
pub mod initializer;
|
||||||
|
pub mod metrics;
|
||||||
pub mod origin;
|
pub mod origin;
|
||||||
pub mod paras;
|
pub mod paras;
|
||||||
pub mod paras_inherent;
|
pub mod paras_inherent;
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Polkadot.
|
||||||
|
|
||||||
|
// Polkadot is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Polkadot is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Runtime declaration of the parachain metrics.
|
||||||
|
|
||||||
|
use polkadot_runtime_metrics::{Counter, CounterVec};
|
||||||
|
use primitives::v1::metric_definitions::{
|
||||||
|
PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS,
|
||||||
|
PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED, PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED,
|
||||||
|
PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED, PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED,
|
||||||
|
PARACHAIN_INHERENT_DATA_WEIGHT,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct Metrics {
|
||||||
|
/// Samples inherent data weight.
|
||||||
|
inherent_data_weight: CounterVec,
|
||||||
|
/// Counts how many inherent bitfields processed in `enter_inner`.
|
||||||
|
bitfields_processed: Counter,
|
||||||
|
/// Counts how many parachain candidates processed in `enter_inner`.
|
||||||
|
candidates_processed: CounterVec,
|
||||||
|
/// Counts dispute statements sets processed in `enter_inner`.
|
||||||
|
dispute_sets_processed: CounterVec,
|
||||||
|
/// Counts dispute statements sets included in `enter_inner`.
|
||||||
|
disputes_included: Counter,
|
||||||
|
/// Counts bitfield signature checks in `enter_inner`.
|
||||||
|
bitfields_signature_checks: CounterVec,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Metrics {
|
||||||
|
/// Sample the inherent data weight metric before filtering.
|
||||||
|
pub fn on_before_filter(&self, value: u64) {
|
||||||
|
self.inherent_data_weight.with_label_values(&["before-filter"]).inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sample the inherent data weight metric after filtering.
|
||||||
|
pub fn on_after_filter(&self, value: u64) {
|
||||||
|
self.inherent_data_weight.with_label_values(&["after-filter"]).inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Increment the number of bitfields processed.
|
||||||
|
pub fn on_bitfields_processed(&self, value: u64) {
|
||||||
|
self.bitfields_processed.inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Increment the number of parachain candidates included.
|
||||||
|
pub fn on_candidates_included(&self, value: u64) {
|
||||||
|
self.candidates_processed.with_label_values(&["included"]).inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Increment the number of parachain candidates sanitized.
|
||||||
|
pub fn on_candidates_sanitized(&self, value: u64) {
|
||||||
|
self.candidates_processed.with_label_values(&["sanitized"]).inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Increment the total number of parachain candidates received in `enter_inner`.
|
||||||
|
pub fn on_candidates_processed_total(&self, value: u64) {
|
||||||
|
self.candidates_processed.with_label_values(&["total"]).inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sample the relay chain freeze events causing runtime to not process candidates in
|
||||||
|
/// `enter_inner`.
|
||||||
|
pub fn on_relay_chain_freeze(&self) {
|
||||||
|
self.dispute_sets_processed.with_label_values(&["frozen"]).inc();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sample the number of dispute sets processed from the current session.
|
||||||
|
pub fn on_current_session_disputes_processed(&self, value: u64) {
|
||||||
|
self.dispute_sets_processed.with_label_values(&["current"]).inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Increment the number of disputes that have concluded as invalid.
|
||||||
|
pub fn on_disputes_concluded_invalid(&self, value: u64) {
|
||||||
|
self.dispute_sets_processed
|
||||||
|
.with_label_values(&["concluded_invalid"])
|
||||||
|
.inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Increment the number of disputes imported.
|
||||||
|
pub fn on_disputes_imported(&self, value: u64) {
|
||||||
|
self.dispute_sets_processed.with_label_values(&["imported"]).inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn on_disputes_included(&self, value: u64) {
|
||||||
|
self.disputes_included.inc_by(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn on_valid_bitfield_signature(&self) {
|
||||||
|
self.bitfields_signature_checks.with_label_values(&["valid"]).inc();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn on_invalid_bitfield_signature(&self) {
|
||||||
|
self.bitfields_signature_checks.with_label_values(&["invalid"]).inc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const METRICS: Metrics = Metrics {
|
||||||
|
inherent_data_weight: CounterVec::new(PARACHAIN_INHERENT_DATA_WEIGHT),
|
||||||
|
bitfields_processed: Counter::new(PARACHAIN_INHERENT_DATA_BITFIELDS_PROCESSED),
|
||||||
|
candidates_processed: CounterVec::new(PARACHAIN_INHERENT_DATA_CANDIDATES_PROCESSED),
|
||||||
|
dispute_sets_processed: CounterVec::new(PARACHAIN_INHERENT_DATA_DISPUTE_SETS_PROCESSED),
|
||||||
|
disputes_included: Counter::new(PARACHAIN_INHERENT_DATA_DISPUTE_SETS_INCLUDED),
|
||||||
|
bitfields_signature_checks: CounterVec::new(
|
||||||
|
PARACHAIN_CREATE_INHERENT_BITFIELDS_SIGNATURE_CHECKS,
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -26,6 +26,7 @@ use crate::{
|
|||||||
inclusion,
|
inclusion,
|
||||||
inclusion::{CandidateCheckContext, FullCheck},
|
inclusion::{CandidateCheckContext, FullCheck},
|
||||||
initializer,
|
initializer,
|
||||||
|
metrics::METRICS,
|
||||||
scheduler::{self, CoreAssignment, FreedReason},
|
scheduler::{self, CoreAssignment, FreedReason},
|
||||||
shared, ump, ParaId,
|
shared, ump, ParaId,
|
||||||
};
|
};
|
||||||
@@ -55,7 +56,6 @@ use sp_std::{
|
|||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
|
|
||||||
use polkadot_runtime_metrics::{Counter, CounterVec};
|
|
||||||
mod misc;
|
mod misc;
|
||||||
mod weights;
|
mod weights;
|
||||||
|
|
||||||
@@ -264,34 +264,6 @@ impl<T: Config> Pallet<T> {
|
|||||||
#[cfg(feature = "runtime-metrics")]
|
#[cfg(feature = "runtime-metrics")]
|
||||||
sp_io::init_tracing();
|
sp_io::init_tracing();
|
||||||
|
|
||||||
let mut weight_metric = CounterVec::new(
|
|
||||||
"parachain_inherent_data_weight",
|
|
||||||
"Inherent data weight before and after filtering",
|
|
||||||
&["when"],
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut bitfields_processed_metric = Counter::new(
|
|
||||||
"parachain_inherent_data_bitfields_processed",
|
|
||||||
"Counts the number of bitfields processed in `enter_inner`.",
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut candidates_processed_metric = CounterVec::new(
|
|
||||||
"parachain_inherent_data_candidates_processed",
|
|
||||||
"Counts the number of parachain block candidates processed in `enter_inner`.",
|
|
||||||
&["category"],
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut dispute_sets_processed_metric = CounterVec::new(
|
|
||||||
"parachain_inherent_data_dispute_sets_processed",
|
|
||||||
"Counts the number of dispute statements sets processed in `enter_inner`.",
|
|
||||||
&["category"],
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut disputes_included_metric = Counter::new(
|
|
||||||
"parachain_inherent_data_disputes_included",
|
|
||||||
"Counts the number of dispute statements sets included in a block in `enter_inner`.",
|
|
||||||
);
|
|
||||||
|
|
||||||
log::debug!(
|
log::debug!(
|
||||||
target: LOG_TARGET,
|
target: LOG_TARGET,
|
||||||
"[enter_inner] parent_header={:?} bitfields.len(): {}, backed_candidates.len(): {}, disputes.len(): {}",
|
"[enter_inner] parent_header={:?} bitfields.len(): {}, backed_candidates.len(): {}, disputes.len(): {}",
|
||||||
@@ -316,9 +288,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
|
|
||||||
let max_block_weight = <T as frame_system::Config>::BlockWeights::get().max_block;
|
let max_block_weight = <T as frame_system::Config>::BlockWeights::get().max_block;
|
||||||
|
|
||||||
weight_metric
|
METRICS.on_before_filter(candidate_weight + bitfields_weight + disputes_weight);
|
||||||
.with_label_values(&["before-filter"])
|
|
||||||
.inc_by(candidate_weight + bitfields_weight + disputes_weight);
|
|
||||||
|
|
||||||
// Potentially trim inherent data to ensure processing will be within weight limits
|
// Potentially trim inherent data to ensure processing will be within weight limits
|
||||||
let total_weight = {
|
let total_weight = {
|
||||||
@@ -366,22 +336,18 @@ impl<T: Config> Pallet<T> {
|
|||||||
// Note that `provide_multi_dispute_data` will iterate, verify, and import each
|
// Note that `provide_multi_dispute_data` will iterate, verify, and import each
|
||||||
// dispute; so the input here must be reasonably bounded.
|
// dispute; so the input here must be reasonably bounded.
|
||||||
let _ = T::DisputesHandler::provide_multi_dispute_data(disputes.clone())?;
|
let _ = T::DisputesHandler::provide_multi_dispute_data(disputes.clone())?;
|
||||||
dispute_sets_processed_metric
|
METRICS.on_disputes_imported(disputes.len() as u64);
|
||||||
.with_label_values(&["imported"])
|
|
||||||
.inc_by(disputes.len() as u64);
|
|
||||||
|
|
||||||
if T::DisputesHandler::is_frozen() {
|
if T::DisputesHandler::is_frozen() {
|
||||||
// Relay chain freeze, at this point we will not include any parachain blocks.
|
// Relay chain freeze, at this point we will not include any parachain blocks.
|
||||||
dispute_sets_processed_metric.with_label_values(&["frozen"]).inc();
|
METRICS.on_relay_chain_freeze();
|
||||||
|
|
||||||
// The relay chain we are currently on is invalid. Proceed no further on parachains.
|
// The relay chain we are currently on is invalid. Proceed no further on parachains.
|
||||||
return Ok(Some(dispute_statements_weight::<T>(&disputes)).into())
|
return Ok(Some(dispute_statements_weight::<T>(&disputes)).into())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the dispute sets of the current session.
|
// Process the dispute sets of the current session.
|
||||||
dispute_sets_processed_metric
|
METRICS.on_current_session_disputes_processed(new_current_dispute_sets.len() as u64);
|
||||||
.with_label_values(&["current"])
|
|
||||||
.inc_by(new_current_dispute_sets.len() as u64);
|
|
||||||
|
|
||||||
let mut freed_disputed = if !new_current_dispute_sets.is_empty() {
|
let mut freed_disputed = if !new_current_dispute_sets.is_empty() {
|
||||||
let concluded_invalid_disputes = new_current_dispute_sets
|
let concluded_invalid_disputes = new_current_dispute_sets
|
||||||
@@ -393,9 +359,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
.collect::<BTreeSet<CandidateHash>>();
|
.collect::<BTreeSet<CandidateHash>>();
|
||||||
|
|
||||||
// Count invalid dispute sets.
|
// Count invalid dispute sets.
|
||||||
dispute_sets_processed_metric
|
METRICS.on_disputes_concluded_invalid(concluded_invalid_disputes.len() as u64);
|
||||||
.with_label_values(&["concluded_invalid"])
|
|
||||||
.inc_by(concluded_invalid_disputes.len() as u64);
|
|
||||||
|
|
||||||
let freed_disputed: Vec<_> =
|
let freed_disputed: Vec<_> =
|
||||||
<inclusion::Pallet<T>>::collect_disputed(&concluded_invalid_disputes)
|
<inclusion::Pallet<T>>::collect_disputed(&concluded_invalid_disputes)
|
||||||
@@ -425,7 +389,8 @@ impl<T: Config> Pallet<T> {
|
|||||||
disputed_bitfield
|
disputed_bitfield
|
||||||
};
|
};
|
||||||
|
|
||||||
bitfields_processed_metric.inc_by(signed_bitfields.len() as u64);
|
METRICS.on_bitfields_processed(signed_bitfields.len() as u64);
|
||||||
|
|
||||||
// Process new availability bitfields, yielding any availability cores whose
|
// Process new availability bitfields, yielding any availability cores whose
|
||||||
// work has now concluded.
|
// work has now concluded.
|
||||||
let freed_concluded = <inclusion::Pallet<T>>::process_bitfields(
|
let freed_concluded = <inclusion::Pallet<T>>::process_bitfields(
|
||||||
@@ -440,17 +405,14 @@ impl<T: Config> Pallet<T> {
|
|||||||
T::DisputesHandler::note_included(current_session, *candidate_hash, now);
|
T::DisputesHandler::note_included(current_session, *candidate_hash, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
candidates_processed_metric
|
METRICS.on_candidates_included(freed_concluded.len() as u64);
|
||||||
.with_label_values(&["included"])
|
|
||||||
.inc_by(freed_concluded.len() as u64);
|
|
||||||
let freed = collect_all_freed_cores::<T, _>(freed_concluded.iter().cloned());
|
let freed = collect_all_freed_cores::<T, _>(freed_concluded.iter().cloned());
|
||||||
|
|
||||||
<scheduler::Pallet<T>>::clear();
|
<scheduler::Pallet<T>>::clear();
|
||||||
<scheduler::Pallet<T>>::schedule(freed, now);
|
<scheduler::Pallet<T>>::schedule(freed, now);
|
||||||
|
|
||||||
candidates_processed_metric
|
METRICS.on_candidates_processed_total(backed_candidates.len() as u64);
|
||||||
.with_label_values(&["total"])
|
|
||||||
.inc_by(backed_candidates.len() as u64);
|
|
||||||
let scheduled = <scheduler::Pallet<T>>::scheduled();
|
let scheduled = <scheduler::Pallet<T>>::scheduled();
|
||||||
let backed_candidates = sanitize_backed_candidates::<T, _>(
|
let backed_candidates = sanitize_backed_candidates::<T, _>(
|
||||||
parent_hash,
|
parent_hash,
|
||||||
@@ -461,9 +423,8 @@ impl<T: Config> Pallet<T> {
|
|||||||
},
|
},
|
||||||
&scheduled[..],
|
&scheduled[..],
|
||||||
);
|
);
|
||||||
candidates_processed_metric
|
|
||||||
.with_label_values(&["sanitized"])
|
METRICS.on_candidates_sanitized(backed_candidates.len() as u64);
|
||||||
.inc_by(backed_candidates.len() as u64);
|
|
||||||
|
|
||||||
// Process backed candidates according to scheduled cores.
|
// Process backed candidates according to scheduled cores.
|
||||||
let parent_storage_root = parent_header.state_root().clone();
|
let parent_storage_root = parent_header.state_root().clone();
|
||||||
@@ -478,7 +439,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
full_check,
|
full_check,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
disputes_included_metric.inc_by(disputes.len() as u64);
|
METRICS.on_disputes_included(disputes.len() as u64);
|
||||||
|
|
||||||
// The number of disputes included in a block is
|
// The number of disputes included in a block is
|
||||||
// limited by the weight as well as the number of candidate blocks.
|
// limited by the weight as well as the number of candidate blocks.
|
||||||
@@ -495,7 +456,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
// this is max config.ump_service_total_weight
|
// this is max config.ump_service_total_weight
|
||||||
let _ump_weight = <ump::Pallet<T>>::process_pending_upward_messages();
|
let _ump_weight = <ump::Pallet<T>>::process_pending_upward_messages();
|
||||||
|
|
||||||
weight_metric.with_label_values(&vec!["after-filter"]).inc_by(total_weight);
|
METRICS.on_after_filter(total_weight);
|
||||||
|
|
||||||
Ok(Some(total_weight).into())
|
Ok(Some(total_weight).into())
|
||||||
}
|
}
|
||||||
@@ -865,12 +826,6 @@ pub(crate) fn sanitize_bitfields<T: crate::inclusion::Config>(
|
|||||||
validators: &[ValidatorId],
|
validators: &[ValidatorId],
|
||||||
full_check: FullCheck,
|
full_check: FullCheck,
|
||||||
) -> UncheckedSignedAvailabilityBitfields {
|
) -> UncheckedSignedAvailabilityBitfields {
|
||||||
let mut bitfields_signature_checks_metric = CounterVec::new(
|
|
||||||
"create_inherent_bitfields_signature_checks",
|
|
||||||
"Counts the number of bitfields signature checked in `enter_inner`.",
|
|
||||||
&["validity"],
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut bitfields = Vec::with_capacity(unchecked_bitfields.len());
|
let mut bitfields = Vec::with_capacity(unchecked_bitfields.len());
|
||||||
|
|
||||||
let mut last_index: Option<ValidatorIndex> = None;
|
let mut last_index: Option<ValidatorIndex> = None;
|
||||||
@@ -941,10 +896,10 @@ pub(crate) fn sanitize_bitfields<T: crate::inclusion::Config>(
|
|||||||
unchecked_bitfield.try_into_checked(&signing_context, validator_public)
|
unchecked_bitfield.try_into_checked(&signing_context, validator_public)
|
||||||
{
|
{
|
||||||
bitfields.push(signed_bitfield.into_unchecked());
|
bitfields.push(signed_bitfield.into_unchecked());
|
||||||
bitfields_signature_checks_metric.with_label_values(&["valid"]).inc();
|
METRICS.on_valid_bitfield_signature();
|
||||||
} else {
|
} else {
|
||||||
log::warn!(target: LOG_TARGET, "Invalid bitfield signature");
|
log::warn!(target: LOG_TARGET, "Invalid bitfield signature");
|
||||||
bitfields_signature_checks_metric.with_label_values(&["invalid"]).inc();
|
METRICS.on_invalid_bitfield_signature();
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
bitfields.push(unchecked_bitfield);
|
bitfields.push(unchecked_bitfield);
|
||||||
|
|||||||
Reference in New Issue
Block a user