Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridge: fixed relayer version metric value #4492

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions bridges/relays/lib-substrate-relay/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ impl PrometheusParams {
None
};

let relay_version = option_env!("CARGO_PKG_VERSION").unwrap_or("unknown");
let relay_version = relay_utils::initialize::RELAYER_VERSION
.lock()
.clone()
.unwrap_or_else(|| "unknown".to_string());
let relay_commit = SubstrateRelayBuildInfo::get_git_commit();
relay_utils::metrics::MetricsParams::new(
metrics_address,
relay_version.into(),
relay_commit,
)
.map_err(|e| anyhow::format_err!("{:?}", e))
relay_utils::metrics::MetricsParams::new(metrics_address, relay_version, relay_commit)
.map_err(|e| anyhow::format_err!("{:?}", e))
}
}

Expand Down
1 change: 1 addition & 0 deletions bridges/relays/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ futures = "0.3.30"
jsonpath_lib = "0.3"
log = { workspace = true }
num-traits = "0.2"
parking_lot = "0.12.1"
serde_json = { workspace = true, default-features = true }
sysinfo = "0.30"
time = { version = "0.3", features = ["formatting", "local-offset", "std"] }
Expand Down
5 changes: 5 additions & 0 deletions bridges/relays/utils/src/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@

//! Relayer initialization functions.
use parking_lot::Mutex;
use std::{cell::RefCell, fmt::Display, io::Write};

/// Relayer version that is provided as metric. Must be set by a binary
/// (get it with `option_env!("CARGO_PKG_VERSION")` from a binary package code).
pub static RELAYER_VERSION: Mutex<Option<String>> = Mutex::new(None);

async_std::task_local! {
pub(crate) static LOOP_NAME: RefCell<String> = RefCell::new(String::default());
}
Expand Down
Loading