mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 18:11:03 +00:00
Add prometheus metrics for block authorship (#10316)
* Add prom metric to basic authorship * Add proposer_block_proposal_time * +nightly-2021-10-29 fmt * Use saturating_duration_since, not elasped * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update client/basic-authorship/src/basic_authorship.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * +nightly-2021-10-29 fmt Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -346,10 +346,23 @@ where
|
|||||||
block_size_limit: Option<usize>,
|
block_size_limit: Option<usize>,
|
||||||
) -> Result<Proposal<Block, backend::TransactionFor<B, Block>, PR::Proof>, sp_blockchain::Error>
|
) -> Result<Proposal<Block, backend::TransactionFor<B, Block>, PR::Proof>, sp_blockchain::Error>
|
||||||
{
|
{
|
||||||
|
let propose_with_start = time::Instant::now();
|
||||||
let mut block_builder =
|
let mut block_builder =
|
||||||
self.client.new_block_at(&self.parent_id, inherent_digests, PR::ENABLED)?;
|
self.client.new_block_at(&self.parent_id, inherent_digests, PR::ENABLED)?;
|
||||||
|
|
||||||
for inherent in block_builder.create_inherents(inherent_data)? {
|
let create_inherents_start = time::Instant::now();
|
||||||
|
let inherents = block_builder.create_inherents(inherent_data)?;
|
||||||
|
let create_inherents_end = time::Instant::now();
|
||||||
|
|
||||||
|
self.metrics.report(|metrics| {
|
||||||
|
metrics.create_inherents_time.observe(
|
||||||
|
create_inherents_end
|
||||||
|
.saturating_duration_since(create_inherents_start)
|
||||||
|
.as_secs_f64(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
for inherent in inherents {
|
||||||
match block_builder.push(inherent) {
|
match block_builder.push(inherent) {
|
||||||
Err(ApplyExtrinsicFailed(Validity(e))) if e.exhausted_resources() => {
|
Err(ApplyExtrinsicFailed(Validity(e))) if e.exhausted_resources() => {
|
||||||
warn!("⚠️ Dropping non-mandatory inherent from overweight block.")
|
warn!("⚠️ Dropping non-mandatory inherent from overweight block.")
|
||||||
@@ -529,6 +542,14 @@ where
|
|||||||
|
|
||||||
let proof =
|
let proof =
|
||||||
PR::into_proof(proof).map_err(|e| sp_blockchain::Error::Application(Box::new(e)))?;
|
PR::into_proof(proof).map_err(|e| sp_blockchain::Error::Application(Box::new(e)))?;
|
||||||
|
|
||||||
|
let propose_with_end = time::Instant::now();
|
||||||
|
self.metrics.report(|metrics| {
|
||||||
|
metrics.create_block_proposal_time.observe(
|
||||||
|
propose_with_end.saturating_duration_since(propose_with_start).as_secs_f64(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
Ok(Proposal { block, proof, storage_changes })
|
Ok(Proposal { block, proof, storage_changes })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ impl MetricsLink {
|
|||||||
pub struct Metrics {
|
pub struct Metrics {
|
||||||
pub block_constructed: Histogram,
|
pub block_constructed: Histogram,
|
||||||
pub number_of_transactions: Gauge<U64>,
|
pub number_of_transactions: Gauge<U64>,
|
||||||
|
pub create_inherents_time: Histogram,
|
||||||
|
pub create_block_proposal_time: Histogram,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Metrics {
|
impl Metrics {
|
||||||
@@ -66,6 +68,20 @@ impl Metrics {
|
|||||||
)?,
|
)?,
|
||||||
registry,
|
registry,
|
||||||
)?,
|
)?,
|
||||||
|
create_inherents_time: register(
|
||||||
|
Histogram::with_opts(HistogramOpts::new(
|
||||||
|
"proposer_create_inherents_time",
|
||||||
|
"Histogram of time taken to execute create inherents",
|
||||||
|
))?,
|
||||||
|
registry,
|
||||||
|
)?,
|
||||||
|
create_block_proposal_time: register(
|
||||||
|
Histogram::with_opts(HistogramOpts::new(
|
||||||
|
"proposer_block_proposal_time",
|
||||||
|
"Histogram of time taken to construct a block and prepare it for proposal",
|
||||||
|
))?,
|
||||||
|
registry,
|
||||||
|
)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user