Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[statement-distribution] Add metrics for distributed statements in V2 #4554

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions polkadot/node/network/statement-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,14 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
);
},
MuxedMessage::Response(result) => {
v2::handle_response(&mut ctx, &mut state, result, &mut self.reputation).await;
v2::handle_response(
&mut ctx,
&mut state,
result,
&mut self.reputation,
&self.metrics,
)
.await;
},
MuxedMessage::RetryRequest(()) => {
// A pending request is ready to retry. This is only a signal to call
Expand Down Expand Up @@ -320,7 +327,8 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
let mode = prospective_parachains_mode(ctx.sender(), activated.hash).await?;
if let ProspectiveParachainsMode::Enabled { .. } = mode {
let res =
v2::handle_active_leaves_update(ctx, state, activated, mode).await;
v2::handle_active_leaves_update(ctx, state, activated, mode, &metrics)
.await;
// Regardless of the result of leaf activation, we always prune before
// handling it to avoid leaks.
v2::handle_deactivate_leaves(state, &deactivated);
Expand Down Expand Up @@ -370,6 +378,7 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
relay_parent,
statement,
&mut self.reputation,
&self.metrics,
)
.await?;
}
Expand Down Expand Up @@ -428,11 +437,24 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {

if target.targets_current() {
// pass to v2.
v2::handle_network_update(ctx, state, event, &mut self.reputation).await;
v2::handle_network_update(
ctx,
state,
event,
&mut self.reputation,
&self.metrics,
)
.await;
}
},
StatementDistributionMessage::Backed(candidate_hash) => {
crate::v2::handle_backed_candidate_message(ctx, state, candidate_hash).await;
crate::v2::handle_backed_candidate_message(
ctx,
state,
candidate_hash,
&self.metrics,
)
.await;
},
},
}
Expand Down
9 changes: 8 additions & 1 deletion polkadot/node/network/statement-distribution/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const HISTOGRAM_LATENCY_BUCKETS: &[f64] = &[
#[derive(Clone)]
struct MetricsInner {
// V1
statements_distributed: prometheus::Counter<prometheus::U64>,
sent_requests: prometheus::Counter<prometheus::U64>,
received_responses: prometheus::CounterVec<prometheus::U64>,
network_bridge_update: prometheus::HistogramVec,
statements_unexpected: prometheus::CounterVec<prometheus::U64>,
created_message_size: prometheus::Gauge<prometheus::U64>,
// V1+
statements_distributed: prometheus::Counter<prometheus::U64>,
active_leaves_update: prometheus::Histogram,
share: prometheus::Histogram,
// V2+
Expand All @@ -51,6 +51,13 @@ impl Metrics {
}
}

/// Update statements distributed counter by an amount
pub fn on_statements_distributed(&self, n: usize) {
if let Some(metrics) = &self.0 {
metrics.statements_distributed.inc_by(n as u64);
}
}

/// Update sent requests counter
/// This counter is updated merely for the statements sent via request/response method,
/// meaning that it counts large statements only
Expand Down
Loading
Loading