mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Switch to latest Jaeger and improve the spans (#2216)
* Switch to latest Jaeger and improve the spans * Update node/jaeger/src/lib.rs Co-authored-by: Robert Habermeier <rphmeier@gmail.com> * Use better span in bitfield signing * Update node/core/bitfield-signing/src/lib.rs Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: Robert Habermeier <rphmeier@gmail.com> Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
Generated
+2
-2
@@ -3477,9 +3477,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mick-jaeger"
|
name = "mick-jaeger"
|
||||||
version = "0.1.2"
|
version = "0.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4247b181b96e62eacb5a1e7a2f1a39a78b945cb0434c0fceaae4ed1882555957"
|
checksum = "c023c3f16109e7f33aa451f773fd61070e265b4977d0b6e344a51049296dd7df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures 0.3.8",
|
"futures 0.3.8",
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ async fn get_core_availability(
|
|||||||
span: &jaeger::JaegerSpan,
|
span: &jaeger::JaegerSpan,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
if let CoreState::Occupied(core) = core {
|
if let CoreState::Occupied(core) = core {
|
||||||
let _span = span.child("query chunk availability");
|
let _span = span.child("query-chunk-availability");
|
||||||
|
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
sender
|
sender
|
||||||
@@ -246,12 +246,12 @@ impl JobTrait for BitfieldSigningJob {
|
|||||||
let _timer = metrics.time_run();
|
let _timer = metrics.time_run();
|
||||||
|
|
||||||
drop(_span);
|
drop(_span);
|
||||||
let _span = span.child("availablity");
|
let span_availability = span.child("availability");
|
||||||
|
|
||||||
let bitfield =
|
let bitfield =
|
||||||
match construct_availability_bitfield(
|
match construct_availability_bitfield(
|
||||||
relay_parent,
|
relay_parent,
|
||||||
&span,
|
&span_availability,
|
||||||
validator.index(),
|
validator.index(),
|
||||||
&mut sender,
|
&mut sender,
|
||||||
).await
|
).await
|
||||||
@@ -265,7 +265,7 @@ impl JobTrait for BitfieldSigningJob {
|
|||||||
Ok(bitfield) => bitfield,
|
Ok(bitfield) => bitfield,
|
||||||
};
|
};
|
||||||
|
|
||||||
drop(_span);
|
drop(span_availability);
|
||||||
let _span = span.child("signing");
|
let _span = span.child("signing");
|
||||||
|
|
||||||
let signed_bitfield = validator
|
let signed_bitfield = validator
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ description = "Polkadot Jaeger primitives"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-std = "1.8.0"
|
async-std = "1.8.0"
|
||||||
mick-jaeger = "0.1.2"
|
mick-jaeger = "0.1.4"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
polkadot-primitives = { path = "../../primitives" }
|
polkadot-primitives = { path = "../../primitives" }
|
||||||
|
|||||||
@@ -183,6 +183,14 @@ impl JaegerSpan {
|
|||||||
Self::Disabled => {},
|
Self::Disabled => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds the `FollowsFrom` relationship to this span with respect to the given one.
|
||||||
|
pub fn add_follows_from(&mut self, other: &Self) {
|
||||||
|
match (self, other) {
|
||||||
|
(Self::Enabled(ref mut inner), Self::Enabled(ref other_inner)) => inner.add_follows_from(&other_inner),
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for JaegerSpan {
|
impl std::fmt::Debug for JaegerSpan {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ use polkadot_subsystem::messages::{
|
|||||||
NetworkBridgeMessage, RuntimeApiMessage, RuntimeApiRequest,
|
NetworkBridgeMessage, RuntimeApiMessage, RuntimeApiRequest,
|
||||||
};
|
};
|
||||||
use polkadot_subsystem::{
|
use polkadot_subsystem::{
|
||||||
jaeger, errors::{ChainApiError, RuntimeApiError},
|
jaeger, errors::{ChainApiError, RuntimeApiError}, PerLeafSpan,
|
||||||
ActiveLeavesUpdate, FromOverseer, OverseerSignal, SpawnedSubsystem, Subsystem, SubsystemContext, SubsystemError,
|
ActiveLeavesUpdate, FromOverseer, OverseerSignal, SpawnedSubsystem, Subsystem, SubsystemContext, SubsystemError,
|
||||||
};
|
};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
@@ -191,12 +191,14 @@ impl PerCandidate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug)]
|
||||||
struct PerRelayParent {
|
struct PerRelayParent {
|
||||||
/// Set of `K` ancestors for this relay parent.
|
/// Set of `K` ancestors for this relay parent.
|
||||||
ancestors: Vec<Hash>,
|
ancestors: Vec<Hash>,
|
||||||
/// Live candidates, according to this relay parent.
|
/// Live candidates, according to this relay parent.
|
||||||
live_candidates: HashSet<CandidateHash>,
|
live_candidates: HashSet<CandidateHash>,
|
||||||
|
/// The span that belongs to this relay parent.
|
||||||
|
span: PerLeafSpan,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProtocolState {
|
impl ProtocolState {
|
||||||
@@ -216,7 +218,7 @@ impl ProtocolState {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "trace", skip(candidates), fields(subsystem = LOG_TARGET))]
|
#[tracing::instrument(level = "trace", skip(candidates, span), fields(subsystem = LOG_TARGET))]
|
||||||
fn add_relay_parent(
|
fn add_relay_parent(
|
||||||
&mut self,
|
&mut self,
|
||||||
relay_parent: Hash,
|
relay_parent: Hash,
|
||||||
@@ -224,10 +226,13 @@ impl ProtocolState {
|
|||||||
validator_index: Option<ValidatorIndex>,
|
validator_index: Option<ValidatorIndex>,
|
||||||
candidates: HashMap<CandidateHash, FetchedLiveCandidate>,
|
candidates: HashMap<CandidateHash, FetchedLiveCandidate>,
|
||||||
ancestors: Vec<Hash>,
|
ancestors: Vec<Hash>,
|
||||||
|
span: PerLeafSpan,
|
||||||
) {
|
) {
|
||||||
let per_relay_parent = self.per_relay_parent.entry(relay_parent).or_default();
|
let per_relay_parent = self.per_relay_parent.entry(relay_parent).or_insert_with(|| PerRelayParent {
|
||||||
per_relay_parent.ancestors = ancestors;
|
span,
|
||||||
per_relay_parent.live_candidates.extend(candidates.keys().cloned());
|
ancestors,
|
||||||
|
live_candidates: candidates.keys().cloned().collect(),
|
||||||
|
});
|
||||||
|
|
||||||
// register the relation of relay_parent to candidate..
|
// register the relation of relay_parent to candidate..
|
||||||
for (receipt_hash, fetched) in candidates {
|
for (receipt_hash, fetched) in candidates {
|
||||||
@@ -256,6 +261,11 @@ impl ProtocolState {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Create some span that will make it able to switch between the candidate and relay parent span.
|
||||||
|
let mut span = per_relay_parent.span.child("live-candidate");
|
||||||
|
span.add_string_tag("candidate-hash", &format!("{:?}", receipt_hash));
|
||||||
|
|
||||||
|
candidate_entry.span.add_follows_from(&span);
|
||||||
candidate_entry.live_in.insert(relay_parent);
|
candidate_entry.live_in.insert(relay_parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,7 +375,9 @@ where
|
|||||||
let view = state.view.clone();
|
let view = state.view.clone();
|
||||||
|
|
||||||
// add all the relay parents and fill the cache
|
// add all the relay parents and fill the cache
|
||||||
for added in view.difference(&old_view) {
|
for (added, span) in view.span_per_head().iter().filter(|v| !old_view.contains(&v.0)) {
|
||||||
|
let span = PerLeafSpan::new(span.clone(), "availability-distribution");
|
||||||
|
|
||||||
let validators = query_validators(ctx, *added).await?;
|
let validators = query_validators(ctx, *added).await?;
|
||||||
let validator_index = obtain_our_validator_index(&validators, keystore.clone()).await;
|
let validator_index = obtain_our_validator_index(&validators, keystore.clone()).await;
|
||||||
let (candidates, ancestors)
|
let (candidates, ancestors)
|
||||||
@@ -377,6 +389,7 @@ where
|
|||||||
validator_index,
|
validator_index,
|
||||||
candidates,
|
candidates,
|
||||||
ancestors,
|
ancestors,
|
||||||
|
span,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,7 +449,6 @@ where
|
|||||||
"Retrieved chunk from availability storage",
|
"Retrieved chunk from availability storage",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
let msg = AvailabilityGossipMessage {
|
let msg = AvailabilityGossipMessage {
|
||||||
candidate_hash,
|
candidate_hash,
|
||||||
erasure_chunk,
|
erasure_chunk,
|
||||||
|
|||||||
@@ -1005,9 +1005,14 @@ fn clean_up_receipts_cache_unions_ancestors_and_view() {
|
|||||||
state.per_relay_parent.insert(hash_a, PerRelayParent {
|
state.per_relay_parent.insert(hash_a, PerRelayParent {
|
||||||
ancestors: vec![hash_b],
|
ancestors: vec![hash_b],
|
||||||
live_candidates: HashSet::new(),
|
live_candidates: HashSet::new(),
|
||||||
|
span: PerLeafSpan::new(Arc::new(jaeger::JaegerSpan::Disabled), "test"),
|
||||||
});
|
});
|
||||||
|
|
||||||
state.per_relay_parent.insert(hash_c, PerRelayParent::default());
|
state.per_relay_parent.insert(hash_c, PerRelayParent {
|
||||||
|
ancestors: Vec::new(),
|
||||||
|
live_candidates: HashSet::new(),
|
||||||
|
span: PerLeafSpan::new(Arc::new(jaeger::JaegerSpan::Disabled), "test"),
|
||||||
|
});
|
||||||
|
|
||||||
state.clean_up_live_under_cache();
|
state.clean_up_live_under_cache();
|
||||||
|
|
||||||
@@ -1030,11 +1035,13 @@ fn remove_relay_parent_only_removes_per_candidate_if_final() {
|
|||||||
state.per_relay_parent.insert(hash_a, PerRelayParent {
|
state.per_relay_parent.insert(hash_a, PerRelayParent {
|
||||||
ancestors: vec![],
|
ancestors: vec![],
|
||||||
live_candidates: std::iter::once(candidate_hash_a).collect(),
|
live_candidates: std::iter::once(candidate_hash_a).collect(),
|
||||||
|
span: PerLeafSpan::new(Arc::new(jaeger::JaegerSpan::Disabled), "test"),
|
||||||
});
|
});
|
||||||
|
|
||||||
state.per_relay_parent.insert(hash_b, PerRelayParent {
|
state.per_relay_parent.insert(hash_b, PerRelayParent {
|
||||||
ancestors: vec![],
|
ancestors: vec![],
|
||||||
live_candidates: std::iter::once(candidate_hash_a).collect(),
|
live_candidates: std::iter::once(candidate_hash_a).collect(),
|
||||||
|
span: PerLeafSpan::new(Arc::new(jaeger::JaegerSpan::Disabled), "test"),
|
||||||
});
|
});
|
||||||
|
|
||||||
state.per_candidate.insert(candidate_hash_a, {
|
state.per_candidate.insert(candidate_hash_a, {
|
||||||
@@ -1079,6 +1086,7 @@ fn add_relay_parent_includes_all_live_candidates() {
|
|||||||
None,
|
None,
|
||||||
candidates,
|
candidates,
|
||||||
vec![ancestor_a],
|
vec![ancestor_a],
|
||||||
|
PerLeafSpan::new(Arc::new(jaeger::JaegerSpan::Disabled), "test"),
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
|
|||||||
@@ -1510,7 +1510,7 @@ where
|
|||||||
|
|
||||||
for (hash, number) in std::mem::take(&mut self.leaves) {
|
for (hash, number) in std::mem::take(&mut self.leaves) {
|
||||||
let _ = self.active_leaves.insert(hash, number);
|
let _ = self.active_leaves.insert(hash, number);
|
||||||
let span = self.on_head_activated(&hash);
|
let span = self.on_head_activated(&hash, None);
|
||||||
update.activated.push((hash, span));
|
update.activated.push((hash, span));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1589,7 +1589,7 @@ where
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let span = self.on_head_activated(&block.hash);
|
let span = self.on_head_activated(&block.hash, Some(block.parent_hash));
|
||||||
let mut update = ActiveLeavesUpdate::start_work(block.hash, span);
|
let mut update = ActiveLeavesUpdate::start_work(block.hash, span);
|
||||||
|
|
||||||
if let Some(number) = self.active_leaves.remove(&block.parent_hash) {
|
if let Some(number) = self.active_leaves.remove(&block.parent_hash) {
|
||||||
@@ -1705,7 +1705,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))]
|
#[tracing::instrument(level = "trace", skip(self), fields(subsystem = LOG_TARGET))]
|
||||||
fn on_head_activated(&mut self, hash: &Hash) -> Arc<JaegerSpan> {
|
fn on_head_activated(&mut self, hash: &Hash, parent_hash: Option<Hash>) -> Arc<JaegerSpan> {
|
||||||
self.metrics.on_head_activated();
|
self.metrics.on_head_activated();
|
||||||
if let Some(listeners) = self.activation_external_listeners.remove(hash) {
|
if let Some(listeners) = self.activation_external_listeners.remove(hash) {
|
||||||
for listener in listeners {
|
for listener in listeners {
|
||||||
@@ -1714,7 +1714,13 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let span = Arc::new(jaeger::hash_span(hash, "leave activated"));
|
let mut span = jaeger::hash_span(hash, "leaf-activated");
|
||||||
|
|
||||||
|
if let Some(parent_span) = parent_hash.and_then(|h| self.span_per_active_leaf.get(&h)) {
|
||||||
|
span.add_follows_from(&*parent_span);
|
||||||
|
}
|
||||||
|
|
||||||
|
let span = Arc::new(span);
|
||||||
self.span_per_active_leaf.insert(*hash, span.clone());
|
self.span_per_active_leaf.insert(*hash, span.clone());
|
||||||
span
|
span
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user