This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add counter for unapproved candidates #7491
Merged
paritytech-processbot
merged 9 commits into
master
from
AndreiEres-7124-add-metric-to-count-unapproved-parachain-blocks-contained-in-unfinalized-chain
Aug 10, 2023
+29
−0
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f16ad07
Add counter for unapproved candidates
AndreiEres 74d2fd0
Update metrics
AndreiEres 09fbc9d
Split metrics
AndreiEres 2b72297
Remove depth metric
AndreiEres beb8ada
Print only the oldest unapproved candidates
AndreiEres eb27052
Update logging condition
AndreiEres 384647b
Fix logging condition
AndreiEres 6315e11
Update logging
AndreiEres 1d0fd8f
Update node/core/approval-voting/src/lib.rs
AndreiEres File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,7 @@ struct MetricsInner { | |
time_db_transaction: prometheus::Histogram, | ||
time_recover_and_approve: prometheus::Histogram, | ||
candidate_signatures_requests_total: prometheus::Counter<prometheus::U64>, | ||
unapproved_candidates_in_unfinalized_chain: prometheus::GaugeVec<prometheus::U64>, | ||
} | ||
|
||
/// Approval Voting metrics. | ||
|
@@ -246,6 +247,15 @@ impl Metrics { | |
fn time_recover_and_approve(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> { | ||
self.0.as_ref().map(|metrics| metrics.time_recover_and_approve.start_timer()) | ||
} | ||
|
||
fn on_unapproved_candidates_in_unfinalized_chain(&self, count: usize, depth: usize) { | ||
if let Some(metrics) = &self.0 { | ||
metrics | ||
.unapproved_candidates_in_unfinalized_chain | ||
.with_label_values(&[&count.to_string(), &depth.to_string()]) | ||
.set(count as u64); | ||
} | ||
} | ||
} | ||
|
||
impl metrics::Metrics for Metrics { | ||
|
@@ -336,6 +346,16 @@ impl metrics::Metrics for Metrics { | |
)?, | ||
registry, | ||
)?, | ||
unapproved_candidates_in_unfinalized_chain: prometheus::register( | ||
prometheus::GaugeVec::new( | ||
prometheus::Opts::new( | ||
"polkadot_parachain_approval_unapproved_candidates_in_unfinalized_chain", | ||
"Number of unapproved candidates in unfinalized chain", | ||
), | ||
&["count", "depth"] | ||
)?, | ||
registry, | ||
)?, | ||
}; | ||
|
||
Ok(Metrics(Some(metrics))) | ||
|
@@ -1298,6 +1318,7 @@ async fn handle_from_overseer<Context>( | |
lower_bound, | ||
wakeups, | ||
&mut approved_ancestor_span, | ||
&metrics, | ||
) | ||
.await | ||
{ | ||
|
@@ -1423,9 +1444,11 @@ async fn handle_approved_ancestor<Context>( | |
lower_bound: BlockNumber, | ||
wakeups: &Wakeups, | ||
span: &mut jaeger::Span, | ||
metrics: &Metrics, | ||
) -> SubsystemResult<Option<HighestApprovedAncestorBlock>> { | ||
const MAX_TRACING_WINDOW: usize = 200; | ||
const ABNORMAL_DEPTH_THRESHOLD: usize = 5; | ||
const LOGGING_DEPTH_THRESHOLD: usize = 10; | ||
let mut span = span | ||
.child("handle-approved-ancestor") | ||
.with_stage(jaeger::Stage::ApprovalChecking); | ||
|
@@ -1534,6 +1557,15 @@ async fn handle_approved_ancestor<Context>( | |
unapproved.len(), | ||
entry.candidates().len(), | ||
); | ||
if bits.len() > LOGGING_DEPTH_THRESHOLD { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think this would be excessive output. What's holding finality is basically the oldest unapproved candidates. Let's just print a the candidate hashes of the in the oldest unapproved block only. |
||
gum::trace!( | ||
target: LOG_TARGET, | ||
"Unapproved blocks on depth {}: {:?}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also add the relay chain block hash in the trace. |
||
bits.len(), | ||
unapproved | ||
) | ||
} | ||
metrics.on_unapproved_candidates_in_unfinalized_chain(unapproved.len(), bits.len()); | ||
entry_span.add_uint_tag("unapproved-candidates", unapproved.len() as u64); | ||
for candidate_hash in unapproved { | ||
match db.load_candidate_entry(&candidate_hash)? { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is not what I meant. There should be one
label
, and it's value can becount
ordepth
. I think it's better to have 2 separate Gauge in this case, one measuring depth of first unapproved and the total count of unapproved candidates.