mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Complex headers+messages Millau<->Rialto relay (#878)
* complex headers+messages relay * post-merge fix * fix + test issue with on-demand not starting
This commit is contained in:
committed by
Bastian Köcher
parent
0d60f42b5e
commit
e2131724fb
@@ -78,6 +78,11 @@ impl<BlockNumber: Clone + Copy> TransactionProofsRelayStorage for InMemoryStorag
|
||||
}
|
||||
}
|
||||
|
||||
/// Return prefix that will be used by default to expose Prometheus metrics of the exchange loop.
|
||||
pub fn metrics_prefix<P: TransactionProofPipeline>() -> String {
|
||||
format!("{}_to_{}_Exchange", P::SOURCE_NAME, P::TARGET_NAME)
|
||||
}
|
||||
|
||||
/// Run proofs synchronization.
|
||||
pub async fn run<P: TransactionProofPipeline>(
|
||||
storage: impl TransactionProofsRelayStorage<BlockNumber = BlockNumberOf<P>>,
|
||||
@@ -89,12 +94,9 @@ pub async fn run<P: TransactionProofPipeline>(
|
||||
let exit_signal = exit_signal.shared();
|
||||
|
||||
relay_utils::relay_loop(source_client, target_client)
|
||||
.with_metrics(
|
||||
format!("{}_to_{}_Exchange", P::SOURCE_NAME, P::TARGET_NAME),
|
||||
metrics_params,
|
||||
)
|
||||
.loop_metric(ExchangeLoopMetrics::default())?
|
||||
.standalone_metric(GlobalMetrics::default())?
|
||||
.with_metrics(Some(metrics_prefix::<P>()), metrics_params)
|
||||
.loop_metric(|registry, prefix| ExchangeLoopMetrics::new(registry, prefix))?
|
||||
.standalone_metric(|registry, prefix| GlobalMetrics::new(registry, prefix))?
|
||||
.expose()
|
||||
.await?
|
||||
.run(|source_client, target_client, metrics| {
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
//! Metrics for currency-exchange relay loop.
|
||||
|
||||
use crate::exchange::{BlockNumberOf, RelayedBlockTransactions, TransactionProofPipeline};
|
||||
use relay_utils::metrics::{register, Counter, CounterVec, GaugeVec, Metrics, Opts, Registry, U64};
|
||||
use relay_utils::metrics::{
|
||||
metric_name, register, Counter, CounterVec, GaugeVec, Opts, PrometheusError, Registry, U64,
|
||||
};
|
||||
|
||||
/// Exchange transactions relay metrics.
|
||||
#[derive(Clone)]
|
||||
@@ -30,31 +32,38 @@ pub struct ExchangeLoopMetrics {
|
||||
processed_transactions: CounterVec<U64>,
|
||||
}
|
||||
|
||||
impl Metrics for ExchangeLoopMetrics {
|
||||
fn register(&self, registry: &Registry) -> Result<(), String> {
|
||||
register(self.best_block_numbers.clone(), registry).map_err(|e| e.to_string())?;
|
||||
register(self.processed_blocks.clone(), registry).map_err(|e| e.to_string())?;
|
||||
register(self.processed_transactions.clone(), registry).map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ExchangeLoopMetrics {
|
||||
fn default() -> Self {
|
||||
ExchangeLoopMetrics {
|
||||
best_block_numbers: GaugeVec::new(
|
||||
Opts::new("best_block_numbers", "Best finalized block numbers"),
|
||||
&["type"],
|
||||
)
|
||||
.expect("metric is static and thus valid; qed"),
|
||||
processed_blocks: Counter::new("processed_blocks", "Total number of processed blocks")
|
||||
.expect("metric is static and thus valid; qed"),
|
||||
processed_transactions: CounterVec::new(
|
||||
Opts::new("processed_transactions", "Total number of processed transactions"),
|
||||
&["type"],
|
||||
)
|
||||
.expect("metric is static and thus valid; qed"),
|
||||
}
|
||||
impl ExchangeLoopMetrics {
|
||||
/// Create and register exchange loop metrics.
|
||||
pub fn new(registry: &Registry, prefix: Option<&str>) -> Result<Self, PrometheusError> {
|
||||
Ok(ExchangeLoopMetrics {
|
||||
best_block_numbers: register(
|
||||
GaugeVec::new(
|
||||
Opts::new(
|
||||
metric_name(prefix, "best_block_numbers"),
|
||||
"Best finalized block numbers",
|
||||
),
|
||||
&["type"],
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
processed_blocks: register(
|
||||
Counter::new(
|
||||
metric_name(prefix, "processed_blocks"),
|
||||
"Total number of processed blocks",
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
processed_transactions: register(
|
||||
CounterVec::new(
|
||||
Opts::new(
|
||||
metric_name(prefix, "processed_transactions"),
|
||||
"Total number of processed transactions",
|
||||
),
|
||||
&["type"],
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user