mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 17:21:08 +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:
@@ -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)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user