Unverified Commit 2bdcaaea authored by Andronik Ordian's avatar Andronik Ordian Committed by GitHub
Browse files

approval-voting: more spans and metrics (#2742)

* approval-voting: more spans and metrics

* s/db/approval db
parent 43a26382
Pipeline #131126 canceled with stages
in 5 minutes and 44 seconds
......@@ -502,9 +502,14 @@ impl Transaction {
let _ = self.candidate_entries.insert(hash, entry);
}
/// Returns true if the transaction contains no actions
pub(crate) fn is_empty(&self) -> bool {
self.block_entries.is_empty() && self.candidate_entries.is_empty()
}
/// Write the contents of the transaction, atomically, to the DB.
pub(crate) fn write(self, db: &dyn KeyValueDB) -> Result<()> {
if self.block_entries.is_empty() && self.candidate_entries.is_empty() {
if self.is_empty() {
return Ok(())
}
......
......@@ -109,6 +109,7 @@ struct MetricsInner {
wakeups_triggered_total: prometheus::Counter<prometheus::U64>,
candidate_approval_time_ticks: prometheus::Histogram,
block_approval_time_ticks: prometheus::Histogram,
time_db_transaction: prometheus::Histogram,
}
/// Aproval Voting metrics.
......@@ -157,6 +158,10 @@ impl Metrics {
metrics.block_approval_time_ticks.observe(ticks as f64);
}
}
fn time_db_transaction(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
self.0.as_ref().map(|metrics| metrics.time_db_transaction.start_timer())
}
}
impl metrics::Metrics for Metrics {
......@@ -217,6 +222,15 @@ impl metrics::Metrics for Metrics {
)?,
registry,
)?,
time_db_transaction: prometheus::register(
prometheus::Histogram::with_opts(
prometheus::HistogramOpts::new(
"parachain_time_approval_db_transaction",
"Time spent writing an approval db transaction.",
)
)?,
registry,
)?,
};
Ok(Metrics(Some(metrics)))
......@@ -570,8 +584,12 @@ async fn handle_actions(
}
}
if !transaction.is_empty() {
let _timer = metrics.time_db_transaction();
transaction.write(db)
.map_err(|e| SubsystemError::with_origin("approval-voting", e))?;
}
Ok(conclude)
}
......@@ -1609,6 +1627,11 @@ async fn launch_approval(
let candidate = candidate.clone();
let background = async move {
let _span = jaeger::Span::from_encodable((block_hash, candidate_hash), "launch-approval")
.with_relay_parent(block_hash)
.with_candidate(candidate_hash)
.with_stage(jaeger::Stage::ApprovalChecking);
let available_data = match a_rx.await {
Err(_) => return,
Ok(Ok(a)) => a,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment