diff options
author | Alex <alex@adnab.me> | 2023-03-13 15:46:48 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2023-03-13 15:46:48 +0000 |
commit | 7fcc153e7cfbae61626ca288634a0f4fb4c4b709 (patch) | |
tree | aa39b41d63358277d61f2cb92ef9565a97c1c901 /src | |
parent | dc6be3983300ee3ee10f601cfc04a06563d86f48 (diff) | |
parent | f37ec584b6009b16d1c7f06918889954b22f5afb (diff) | |
download | garage-7fcc153e7cfbae61626ca288634a0f4fb4c4b709.tar.gz garage-7fcc153e7cfbae61626ca288634a0f4fb4c4b709.zip |
Merge pull request 'rpc/system_metrics.rs: Added rustversion label to garage_build_info metric.' (#524) from jpds/garage:rustversion-label into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/524
Diffstat (limited to 'src')
-rw-r--r-- | src/api/admin/cluster.rs | 2 | ||||
-rw-r--r-- | src/garage/admin.rs | 3 | ||||
-rw-r--r-- | src/rpc/system_metrics.rs | 8 | ||||
-rw-r--r-- | src/util/Cargo.toml | 3 | ||||
-rw-r--r-- | src/util/build.rs | 8 | ||||
-rw-r--r-- | src/util/version.rs | 4 |
6 files changed, 23 insertions, 5 deletions
diff --git a/src/api/admin/cluster.rs b/src/api/admin/cluster.rs index 182a4f6f..98bf2b5a 100644 --- a/src/api/admin/cluster.rs +++ b/src/api/admin/cluster.rs @@ -20,6 +20,7 @@ pub async fn handle_get_cluster_status(garage: &Arc<Garage>) -> Result<Response< node: hex::encode(garage.system.id), garage_version: garage_util::version::garage_version(), garage_features: garage_util::version::garage_features(), + rust_version: garage_util::version::rust_version(), db_engine: garage.db.engine(), known_nodes: garage .system @@ -106,6 +107,7 @@ struct GetClusterStatusResponse { node: String, garage_version: &'static str, garage_features: Option<&'static [&'static str]>, + rust_version: &'static str, db_engine: String, known_nodes: HashMap<String, KnownNodeResp>, layout: GetClusterLayoutResponse, diff --git a/src/garage/admin.rs b/src/garage/admin.rs index 2ef3077c..34141cb2 100644 --- a/src/garage/admin.rs +++ b/src/garage/admin.rs @@ -820,11 +820,12 @@ impl AdminRpcHandler { let mut ret = String::new(); writeln!( &mut ret, - "\nGarage version: {} [features: {}]", + "\nGarage version: {} [features: {}]\nRust compiler version: {}", garage_util::version::garage_version(), garage_util::version::garage_features() .map(|list| list.join(", ")) .unwrap_or_else(|| "(unknown)".into()), + garage_util::version::rust_version(), ) .unwrap(); diff --git a/src/rpc/system_metrics.rs b/src/rpc/system_metrics.rs index 83f5fa97..af81b71f 100644 --- a/src/rpc/system_metrics.rs +++ b/src/rpc/system_metrics.rs @@ -31,10 +31,10 @@ impl SystemMetrics { .u64_value_observer("garage_build_info", move |observer| { observer.observe( 1, - &[KeyValue::new( - "version", - garage_util::version::garage_version(), - )], + &[ + KeyValue::new("rustversion", garage_util::version::rust_version()), + KeyValue::new("version", garage_util::version::garage_version()), + ], ) }) .with_description("Garage build info") diff --git a/src/util/Cargo.toml b/src/util/Cargo.toml index abeccbbd..9c182fd6 100644 --- a/src/util/Cargo.toml +++ b/src/util/Cargo.toml @@ -47,6 +47,9 @@ hyper = "0.14" opentelemetry = { version = "0.17", features = [ "rt-tokio", "metrics", "trace" ] } +[build-dependencies] +rustc_version = "0.4.0" + [dev-dependencies] mktemp = "0.5" diff --git a/src/util/build.rs b/src/util/build.rs new file mode 100644 index 00000000..a4e955b8 --- /dev/null +++ b/src/util/build.rs @@ -0,0 +1,8 @@ +use rustc_version::version; + +fn main() { + // Acquire the version of Rust used to compile, this is added as a label to + // the garage_build_info metric. + let v = version().unwrap(); + println!("cargo:rustc-env=RUSTC_VERSION={v}"); +} diff --git a/src/util/version.rs b/src/util/version.rs index b515dccc..2b2ea271 100644 --- a/src/util/version.rs +++ b/src/util/version.rs @@ -26,3 +26,7 @@ pub fn init_version(version: &'static str) { pub fn init_features(features: &'static [&'static str]) { FEATURES.store(Some(Arc::new(features))); } + +pub fn rust_version() -> &'static str { + env!("RUSTC_VERSION") +} |