mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 12:31:03 +00:00
Add one Jaeger span per relay parent (#2196)
* Add one Jaeger span per relay parent This adds one Jaeger span per relay parent, instead of always creating new spans per relay parent. This should improve the UI view, because subsystems are now grouped below one common span. * Fix doc tests * Replace `PerLeaveSpan` to `PerLeafSpan` * More renaming * Moare * Update node/subsystem/src/lib.rs Co-authored-by: Andronik Ordian <write@reusable.software> * Skip the spans * Increase `spec_version` Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
use std::pin::Pin;
|
||||
use std::{pin::Pin, sync::Arc, fmt};
|
||||
|
||||
use futures::prelude::*;
|
||||
use futures::channel::{mpsc, oneshot};
|
||||
@@ -36,8 +36,9 @@ use crate::messages::AllMessages;
|
||||
|
||||
pub mod errors;
|
||||
pub mod messages;
|
||||
pub mod jaeger;
|
||||
pub use crate::jaeger::*;
|
||||
|
||||
pub use polkadot_node_jaeger as jaeger;
|
||||
pub use jaeger::*;
|
||||
|
||||
/// How many slots are stack-reserved for active leaves updates
|
||||
///
|
||||
@@ -48,18 +49,21 @@ const ACTIVE_LEAVES_SMALLVEC_CAPACITY: usize = 8;
|
||||
/// Changes in the set of active leaves: the parachain heads which we care to work on.
|
||||
///
|
||||
/// Note that the activated and deactivated fields indicate deltas, not complete sets.
|
||||
#[derive(Clone, Debug, Default, Eq)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct ActiveLeavesUpdate {
|
||||
/// New relay chain block hashes of interest.
|
||||
pub activated: SmallVec<[Hash; ACTIVE_LEAVES_SMALLVEC_CAPACITY]>,
|
||||
/// New relay chain block hashes of interest and their associated [`JaegerSpan`].
|
||||
///
|
||||
/// NOTE: Each span should only be kept active as long as the leaf is considered active and should be dropped
|
||||
/// when the leaf is deactivated.
|
||||
pub activated: SmallVec<[(Hash, Arc<JaegerSpan>); ACTIVE_LEAVES_SMALLVEC_CAPACITY]>,
|
||||
/// Relay chain block hashes no longer of interest.
|
||||
pub deactivated: SmallVec<[Hash; ACTIVE_LEAVES_SMALLVEC_CAPACITY]>,
|
||||
}
|
||||
|
||||
impl ActiveLeavesUpdate {
|
||||
/// Create a ActiveLeavesUpdate with a single activated hash
|
||||
pub fn start_work(hash: Hash) -> Self {
|
||||
Self { activated: [hash][..].into(), ..Default::default() }
|
||||
pub fn start_work(hash: Hash, span: Arc<JaegerSpan>) -> Self {
|
||||
Self { activated: [(hash, span)][..].into(), ..Default::default() }
|
||||
}
|
||||
|
||||
/// Create a ActiveLeavesUpdate with a single deactivated hash
|
||||
@@ -79,11 +83,27 @@ impl PartialEq for ActiveLeavesUpdate {
|
||||
/// Instead, it means equality when `activated` and `deactivated` are considered as sets.
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.activated.len() == other.activated.len() && self.deactivated.len() == other.deactivated.len()
|
||||
&& self.activated.iter().all(|a| other.activated.contains(a))
|
||||
&& self.activated.iter().all(|a| other.activated.iter().any(|o| a.0 == o.0))
|
||||
&& self.deactivated.iter().all(|a| other.deactivated.contains(a))
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for ActiveLeavesUpdate {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
struct Activated<'a>(&'a [(Hash, Arc<JaegerSpan>)]);
|
||||
impl fmt::Debug for Activated<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_list().entries(self.0.iter().map(|e| e.0)).finish()
|
||||
}
|
||||
}
|
||||
|
||||
f.debug_struct("ActiveLeavesUpdate")
|
||||
.field("activated", &Activated(&self.activated))
|
||||
.field("deactivated", &self.deactivated)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// Signals sent by an overseer to a subsystem.
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
pub enum OverseerSignal {
|
||||
@@ -139,7 +159,7 @@ pub enum SubsystemError {
|
||||
Prometheus(#[from] substrate_prometheus_endpoint::PrometheusError),
|
||||
|
||||
#[error(transparent)]
|
||||
Jaeger(#[from] errors::JaegerError),
|
||||
Jaeger(#[from] JaegerError),
|
||||
|
||||
#[error("Failed to {0}")]
|
||||
Context(String),
|
||||
|
||||
Reference in New Issue
Block a user