mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +00:00
Rework telemetry to replace the use of tracing with an object we pass around (#8143)
polkadot companion: paritytech/polkadot#2535
This commit is contained in:
@@ -32,7 +32,7 @@ use sp_runtime::{
|
||||
traits::{Block as BlockT, Hash as HashT, Header as HeaderT, DigestFor, BlakeTwo256},
|
||||
};
|
||||
use sp_transaction_pool::{TransactionPool, InPoolTransaction};
|
||||
use sc_telemetry::{telemetry, CONSENSUS_INFO};
|
||||
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO};
|
||||
use sc_block_builder::{BlockBuilderApi, BlockBuilderProvider};
|
||||
use sp_api::{ProvideRuntimeApi, ApiExt};
|
||||
use futures::{future, future::{Future, FutureExt}, channel::oneshot, select};
|
||||
@@ -60,9 +60,10 @@ pub struct ProposerFactory<A, B, C, PR> {
|
||||
transaction_pool: Arc<A>,
|
||||
/// Prometheus Link,
|
||||
metrics: PrometheusMetrics,
|
||||
max_block_size: usize,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
/// phantom member to pin the `Backend`/`ProofRecording` type.
|
||||
_phantom: PhantomData<(B, PR)>,
|
||||
max_block_size: usize,
|
||||
}
|
||||
|
||||
impl<A, B, C> ProposerFactory<A, B, C, DisableProofRecording> {
|
||||
@@ -74,14 +75,16 @@ impl<A, B, C> ProposerFactory<A, B, C, DisableProofRecording> {
|
||||
client: Arc<C>,
|
||||
transaction_pool: Arc<A>,
|
||||
prometheus: Option<&PrometheusRegistry>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
) -> Self {
|
||||
ProposerFactory {
|
||||
spawn_handle: Box::new(spawn_handle),
|
||||
client,
|
||||
transaction_pool,
|
||||
metrics: PrometheusMetrics::new(prometheus),
|
||||
_phantom: PhantomData,
|
||||
max_block_size: DEFAULT_MAX_BLOCK_SIZE,
|
||||
telemetry,
|
||||
client,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,14 +98,16 @@ impl<A, B, C> ProposerFactory<A, B, C, EnableProofRecording> {
|
||||
client: Arc<C>,
|
||||
transaction_pool: Arc<A>,
|
||||
prometheus: Option<&PrometheusRegistry>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
) -> Self {
|
||||
ProposerFactory {
|
||||
spawn_handle: Box::new(spawn_handle),
|
||||
client,
|
||||
transaction_pool,
|
||||
metrics: PrometheusMetrics::new(prometheus),
|
||||
_phantom: PhantomData,
|
||||
max_block_size: DEFAULT_MAX_BLOCK_SIZE,
|
||||
telemetry,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,8 +152,9 @@ impl<B, Block, C, A, PR> ProposerFactory<A, B, C, PR>
|
||||
transaction_pool: self.transaction_pool.clone(),
|
||||
now,
|
||||
metrics: self.metrics.clone(),
|
||||
_phantom: PhantomData,
|
||||
max_block_size: self.max_block_size,
|
||||
telemetry: self.telemetry.clone(),
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
|
||||
proposer
|
||||
@@ -189,8 +195,9 @@ pub struct Proposer<B, Block: BlockT, C, A: TransactionPool, PR> {
|
||||
transaction_pool: Arc<A>,
|
||||
now: Box<dyn Fn() -> time::Instant + Send + Sync>,
|
||||
metrics: PrometheusMetrics,
|
||||
_phantom: PhantomData<(B, PR)>,
|
||||
max_block_size: usize,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
_phantom: PhantomData<(B, PR)>,
|
||||
}
|
||||
|
||||
impl<A, B, Block, C, PR> sp_consensus::Proposer<Block> for
|
||||
@@ -371,7 +378,10 @@ impl<A, B, Block, C, PR> Proposer<B, Block, C, A, PR>
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
);
|
||||
telemetry!(CONSENSUS_INFO; "prepared_block_for_proposing";
|
||||
telemetry!(
|
||||
self.telemetry;
|
||||
CONSENSUS_INFO;
|
||||
"prepared_block_for_proposing";
|
||||
"number" => ?block.header().number(),
|
||||
"hash" => ?<Block as BlockT>::Hash::from(block.header().hash()),
|
||||
);
|
||||
@@ -461,6 +471,7 @@ mod tests {
|
||||
client.clone(),
|
||||
txpool.clone(),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
let cell = Mutex::new((false, time::Instant::now()));
|
||||
@@ -508,6 +519,7 @@ mod tests {
|
||||
client.clone(),
|
||||
txpool.clone(),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
let cell = Mutex::new((false, time::Instant::now()));
|
||||
@@ -564,6 +576,7 @@ mod tests {
|
||||
client.clone(),
|
||||
txpool.clone(),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
let proposer = proposer_factory.init_with_now(
|
||||
@@ -639,6 +652,7 @@ mod tests {
|
||||
client.clone(),
|
||||
txpool.clone(),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
let mut propose_block = |
|
||||
client: &TestClient,
|
||||
|
||||
Reference in New Issue
Block a user