Skip to content

Commit

Permalink
Exchange transactions relay dashboard (paritytech#241)
Browse files Browse the repository at this point in the history
* update dashboards

* cargo fmt --all

* Update deployments/rialto/dashboard/prometheus/prometheus.yml

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
  • Loading branch information
2 people authored and serban300 committed Apr 9, 2024
1 parent 25e5ec6 commit 97cb9c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 6 additions & 1 deletion bridges/relays/ethereum/src/exchange_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ pub fn run<P: TransactionProofPipeline>(
let mut metrics_global = GlobalMetrics::new();
let mut metrics_exch = ExchangeLoopMetrics::new();
let metrics_enabled = metrics_params.is_some();
metrics_start(metrics_params, &metrics_global, &metrics_exch);
metrics_start(
format!("{}_to_{}_Exchange", P::SOURCE_NAME, P::TARGET_NAME),
metrics_params,
&metrics_global,
&metrics_exch,
);

let exit_signal = exit_signal.fuse();

Expand Down
12 changes: 10 additions & 2 deletions bridges/relays/ethereum/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ pub struct GlobalMetrics {
}

/// Start Prometheus endpoint with given metrics registry.
pub fn start(params: Option<MetricsParams>, global_metrics: &GlobalMetrics, extra_metrics: &impl Metrics) {
pub fn start(
prefix: String,
params: Option<MetricsParams>,
global_metrics: &GlobalMetrics,
extra_metrics: &impl Metrics,
) {
let params = match params {
Some(params) => params,
None => return,
};

assert!(!prefix.is_empty(), "Metrics prefix can not be empty");

let do_start = move || {
let prometheus_socket_addr = SocketAddr::new(
params
Expand All @@ -59,7 +66,8 @@ pub fn start(params: Option<MetricsParams>, global_metrics: &GlobalMetrics, extr
.map_err(|err| format!("Invalid Prometheus host {}: {}", params.host, err))?,
params.port,
);
let metrics_registry = Registry::new();
let metrics_registry =
Registry::new_custom(Some(prefix), None).expect("only fails if prefix is empty; prefix is not empty; qed");
global_metrics.register(&metrics_registry)?;
extra_metrics.register(&metrics_registry)?;
async_std::task::spawn(async move {
Expand Down
7 changes: 6 additions & 1 deletion bridges/relays/ethereum/src/sync_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ pub fn run<P: HeadersSyncPipeline, TC: TargetClient<P>>(
let mut metrics_global = GlobalMetrics::new();
let mut metrics_sync = SyncLoopMetrics::new();
let metrics_enabled = metrics_params.is_some();
metrics_start(metrics_params, &metrics_global, &metrics_sync);
metrics_start(
format!("{}_to_{}_Sync", P::SOURCE_NAME, P::TARGET_NAME),
metrics_params,
&metrics_global,
&metrics_sync,
);

let mut source_retry_backoff = retry_backoff();
let mut source_client_is_online = false;
Expand Down

0 comments on commit 97cb9c4

Please sign in to comment.