mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 17:51:09 +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:
@@ -26,7 +26,6 @@ sc-service = { git = "https://github.com/paritytech/substrate", branch = "master
|
||||
log = "0.4.11"
|
||||
env_logger = "0.8.2"
|
||||
assert_matches = "1.4.0"
|
||||
smallvec = "1.5.1"
|
||||
kvdb-memorydb = "0.7.0"
|
||||
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -534,7 +534,7 @@ where
|
||||
FromOverseer::Signal(OverseerSignal::ActiveLeaves(
|
||||
ActiveLeavesUpdate { activated, .. })
|
||||
) => {
|
||||
for activated in activated.into_iter() {
|
||||
for (activated, _span) in activated.into_iter() {
|
||||
process_block_activated(ctx, &subsystem.inner, activated, &subsystem.metrics).await?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ use futures::{
|
||||
executor,
|
||||
Future,
|
||||
};
|
||||
use smallvec::smallvec;
|
||||
|
||||
use polkadot_primitives::v1::{
|
||||
AvailableData, BlockData, CandidateDescriptor, CandidateReceipt, HeadData,
|
||||
@@ -31,7 +30,7 @@ use polkadot_primitives::v1::{
|
||||
};
|
||||
use polkadot_node_subsystem_util::TimeoutExt;
|
||||
use polkadot_subsystem::{
|
||||
ActiveLeavesUpdate, errors::RuntimeApiError,
|
||||
ActiveLeavesUpdate, errors::RuntimeApiError, JaegerSpan,
|
||||
};
|
||||
use polkadot_node_subsystem_test_helpers as test_helpers;
|
||||
|
||||
@@ -182,8 +181,8 @@ fn runtime_api_error_does_not_stop_the_subsystem() {
|
||||
overseer_signal(
|
||||
&mut virtual_overseer,
|
||||
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
|
||||
activated: smallvec![new_leaf.clone()],
|
||||
deactivated: smallvec![],
|
||||
activated: vec![(new_leaf, Arc::new(JaegerSpan::Disabled))].into(),
|
||||
deactivated: vec![].into(),
|
||||
}),
|
||||
).await;
|
||||
|
||||
@@ -516,8 +515,8 @@ fn stored_data_kept_until_finalized() {
|
||||
overseer_signal(
|
||||
&mut virtual_overseer,
|
||||
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
|
||||
activated: smallvec![new_leaf.clone()],
|
||||
deactivated: smallvec![],
|
||||
activated: vec![(new_leaf, Arc::new(JaegerSpan::Disabled))].into(),
|
||||
deactivated: vec![].into(),
|
||||
}),
|
||||
).await;
|
||||
|
||||
@@ -620,8 +619,8 @@ fn stored_chunk_kept_until_finalized() {
|
||||
overseer_signal(
|
||||
&mut virtual_overseer,
|
||||
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
|
||||
activated: smallvec![new_leaf.clone()],
|
||||
deactivated: smallvec![],
|
||||
activated: vec![(new_leaf, Arc::new(JaegerSpan::Disabled))].into(),
|
||||
deactivated: vec![].into(),
|
||||
}),
|
||||
).await;
|
||||
|
||||
@@ -758,8 +757,8 @@ fn forkfullness_works() {
|
||||
overseer_signal(
|
||||
&mut virtual_overseer,
|
||||
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate {
|
||||
activated: smallvec![new_leaf_1.clone(), new_leaf_2.clone()],
|
||||
deactivated: smallvec![],
|
||||
activated: vec![(new_leaf_1, Arc::new(JaegerSpan::Disabled)), (new_leaf_2, Arc::new(JaegerSpan::Disabled))].into(),
|
||||
deactivated: vec![].into(),
|
||||
}),
|
||||
).await;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ use polkadot_node_primitives::{
|
||||
FromTableMisbehavior, Statement, SignedFullStatement, MisbehaviorReport, ValidationResult,
|
||||
};
|
||||
use polkadot_subsystem::{
|
||||
jaeger::{self, JaegerSpan},
|
||||
JaegerSpan, PerLeafSpan,
|
||||
messages::{
|
||||
AllMessages, AvailabilityStoreMessage, CandidateBackingMessage, CandidateSelectionMessage,
|
||||
CandidateValidationMessage, PoVDistributionMessage, ProvisionableData,
|
||||
@@ -923,9 +923,10 @@ impl util::JobTrait for CandidateBackingJob {
|
||||
|
||||
const NAME: &'static str = "CandidateBackingJob";
|
||||
|
||||
#[tracing::instrument(skip(keystore, metrics, rx_to, tx_from), fields(subsystem = LOG_TARGET))]
|
||||
#[tracing::instrument(skip(span, keystore, metrics, rx_to, tx_from), fields(subsystem = LOG_TARGET))]
|
||||
fn run(
|
||||
parent: Hash,
|
||||
span: Arc<JaegerSpan>,
|
||||
keystore: SyncCryptoStorePtr,
|
||||
metrics: Metrics,
|
||||
rx_to: mpsc::Receiver<Self::ToJob>,
|
||||
@@ -952,7 +953,7 @@ impl util::JobTrait for CandidateBackingJob {
|
||||
}
|
||||
}
|
||||
|
||||
let span = jaeger::hash_span(&parent, "run:backing");
|
||||
let span = PerLeafSpan::new(span, "backing");
|
||||
let _span = span.child("runtime-apis");
|
||||
|
||||
let (validators, groups, session_index, cores) = futures::try_join!(
|
||||
@@ -1340,7 +1341,10 @@ mod tests {
|
||||
) {
|
||||
// Start work on some new parent.
|
||||
virtual_overseer.send(FromOverseer::Signal(
|
||||
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(test_state.relay_parent)))
|
||||
OverseerSignal::ActiveLeaves(ActiveLeavesUpdate::start_work(
|
||||
test_state.relay_parent,
|
||||
Arc::new(JaegerSpan::Disabled),
|
||||
)))
|
||||
).await;
|
||||
|
||||
// Check that subsystem job issues a request for a validator set.
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
use futures::{channel::{mpsc, oneshot}, lock::Mutex, prelude::*, future, Future};
|
||||
use sp_keystore::{Error as KeystoreError, SyncCryptoStorePtr};
|
||||
use polkadot_node_subsystem::{
|
||||
jaeger,
|
||||
jaeger, PerLeafSpan, JaegerSpan,
|
||||
messages::{
|
||||
AllMessages, AvailabilityStoreMessage, BitfieldDistributionMessage,
|
||||
BitfieldSigningMessage, RuntimeApiMessage, RuntimeApiRequest,
|
||||
@@ -34,7 +34,7 @@ use polkadot_node_subsystem_util::{
|
||||
self as util, JobManager, JobTrait, Validator, FromJobCommand, metrics::{self, prometheus},
|
||||
};
|
||||
use polkadot_primitives::v1::{AvailabilityBitfield, CoreState, Hash, ValidatorIndex};
|
||||
use std::{pin::Pin, time::Duration, iter::FromIterator};
|
||||
use std::{pin::Pin, time::Duration, iter::FromIterator, sync::Arc};
|
||||
use wasm_timer::{Delay, Instant};
|
||||
|
||||
/// Delay between starting a bitfield signing job and its attempting to create a bitfield.
|
||||
@@ -215,9 +215,10 @@ impl JobTrait for BitfieldSigningJob {
|
||||
const NAME: &'static str = "BitfieldSigningJob";
|
||||
|
||||
/// Run a job for the parent block indicated
|
||||
#[tracing::instrument(skip(keystore, metrics, _receiver, sender), fields(subsystem = LOG_TARGET))]
|
||||
#[tracing::instrument(skip(span, keystore, metrics, _receiver, sender), fields(subsystem = LOG_TARGET))]
|
||||
fn run(
|
||||
relay_parent: Hash,
|
||||
span: Arc<JaegerSpan>,
|
||||
keystore: Self::RunArgs,
|
||||
metrics: Self::Metrics,
|
||||
_receiver: mpsc::Receiver<BitfieldSigningMessage>,
|
||||
@@ -225,7 +226,7 @@ impl JobTrait for BitfieldSigningJob {
|
||||
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send>> {
|
||||
let metrics = metrics.clone();
|
||||
async move {
|
||||
let span = jaeger::hash_span(&relay_parent, "run:bitfield-signing");
|
||||
let span = PerLeafSpan::new(span, "bitfield-signing");
|
||||
let _span = span.child("delay");
|
||||
let wait_until = Instant::now() + JOB_DELAY;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ use futures::{
|
||||
};
|
||||
use sp_keystore::SyncCryptoStorePtr;
|
||||
use polkadot_node_subsystem::{
|
||||
jaeger,
|
||||
jaeger, JaegerSpan, PerLeafSpan,
|
||||
errors::ChainApiError,
|
||||
messages::{
|
||||
AllMessages, CandidateBackingMessage, CandidateSelectionMessage, CollatorProtocolMessage,
|
||||
@@ -39,7 +39,7 @@ use polkadot_node_subsystem_util::{
|
||||
use polkadot_primitives::v1::{
|
||||
CandidateReceipt, CollatorId, CoreState, CoreIndex, Hash, Id as ParaId, PoV,
|
||||
};
|
||||
use std::pin::Pin;
|
||||
use std::{pin::Pin, sync::Arc};
|
||||
use thiserror::Error;
|
||||
|
||||
const LOG_TARGET: &'static str = "candidate_selection";
|
||||
@@ -95,12 +95,13 @@ impl JobTrait for CandidateSelectionJob {
|
||||
#[tracing::instrument(skip(keystore, metrics, receiver, sender), fields(subsystem = LOG_TARGET))]
|
||||
fn run(
|
||||
relay_parent: Hash,
|
||||
span: Arc<JaegerSpan>,
|
||||
keystore: Self::RunArgs,
|
||||
metrics: Self::Metrics,
|
||||
receiver: mpsc::Receiver<CandidateSelectionMessage>,
|
||||
mut sender: mpsc::Sender<FromJobCommand>,
|
||||
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send>> {
|
||||
let span = jaeger::hash_span(&relay_parent, "candidate-selection:run");
|
||||
let span = PerLeafSpan::new(span, "candidate-selection");
|
||||
async move {
|
||||
let _span = span.child("query-runtime");
|
||||
let (groups, cores) = futures::try_join!(
|
||||
|
||||
@@ -25,8 +25,7 @@ use futures::{
|
||||
prelude::*,
|
||||
};
|
||||
use polkadot_node_subsystem::{
|
||||
errors::{ChainApiError, RuntimeApiError},
|
||||
jaeger,
|
||||
errors::{ChainApiError, RuntimeApiError}, PerLeafSpan, JaegerSpan,
|
||||
messages::{
|
||||
AllMessages, CandidateBackingMessage, ChainApiMessage, ProvisionableData, ProvisionerInherentData,
|
||||
ProvisionerMessage,
|
||||
@@ -40,7 +39,7 @@ use polkadot_primitives::v1::{
|
||||
BackedCandidate, BlockNumber, CandidateReceipt, CoreState, Hash, OccupiedCoreAssumption,
|
||||
SignedAvailabilityBitfield, ValidatorIndex,
|
||||
};
|
||||
use std::{pin::Pin, collections::BTreeMap};
|
||||
use std::{pin::Pin, collections::BTreeMap, sync::Arc};
|
||||
use thiserror::Error;
|
||||
use futures_timer::Delay;
|
||||
|
||||
@@ -140,9 +139,10 @@ impl JobTrait for ProvisioningJob {
|
||||
/// Run a job for the parent block indicated
|
||||
//
|
||||
// this function is in charge of creating and executing the job's main loop
|
||||
#[tracing::instrument(skip(_run_args, metrics, receiver, sender), fields(subsystem = LOG_TARGET))]
|
||||
#[tracing::instrument(skip(span, _run_args, metrics, receiver, sender), fields(subsystem = LOG_TARGET))]
|
||||
fn run(
|
||||
relay_parent: Hash,
|
||||
span: Arc<JaegerSpan>,
|
||||
_run_args: Self::RunArgs,
|
||||
metrics: Self::Metrics,
|
||||
receiver: mpsc::Receiver<ProvisionerMessage>,
|
||||
@@ -156,11 +156,7 @@ impl JobTrait for ProvisioningJob {
|
||||
receiver,
|
||||
);
|
||||
|
||||
let span = jaeger::hash_span(&relay_parent, "provisioner");
|
||||
|
||||
// it isn't necessary to break run_loop into its own function,
|
||||
// but it's convenient to separate the concerns in this way
|
||||
job.run_loop(&span).await
|
||||
job.run_loop(PerLeafSpan::new(span, "provisioner")).await
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
@@ -186,7 +182,7 @@ impl ProvisioningJob {
|
||||
}
|
||||
}
|
||||
|
||||
async fn run_loop(mut self, span: &jaeger::JaegerSpan) -> Result<(), Error> {
|
||||
async fn run_loop(mut self, span: PerLeafSpan) -> Result<(), Error> {
|
||||
use ProvisionerMessage::{
|
||||
ProvisionableData, RequestBlockAuthorshipData, RequestInherentData,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user