From 25f2a46fc3e50c882cd518244bb49d44d01ca442 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 10 Mar 2023 11:40:58 +0000 Subject: [PATCH 1/4] rpc/system_metrics.rs: Added rustversion label to garage_build_info metric. --- Cargo.lock | 1 + src/rpc/system_metrics.rs | 8 ++++---- src/util/Cargo.toml | 3 +++ src/util/build.rs | 8 ++++++++ src/util/version.rs | 4 ++++ 5 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/util/build.rs diff --git a/Cargo.lock b/Cargo.lock index 4fddd215..981af01d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1309,6 +1309,7 @@ dependencies = [ "opentelemetry", "rand", "rmp-serde", + "rustc_version", "serde", "serde_json", "sha2 0.10.6", 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") +} From 4421378023465c72ba8e693c949c85c51d96929e Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 10 Mar 2023 14:45:00 +0000 Subject: [PATCH 2/4] garage/admin.rs: Display Rust version in stats output. --- src/garage/admin.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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(); From 9ea154ae9c6b12175192419679ec1bc40da827d1 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 10 Mar 2023 14:45:18 +0000 Subject: [PATCH 3/4] admin/cluster.rs: Added rust_version. --- src/api/admin/cluster.rs | 2 ++ 1 file changed, 2 insertions(+) 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) -> Result, + rust_version: &'static str, db_engine: String, known_nodes: HashMap, layout: GetClusterLayoutResponse, From 40fa1242f080ba69159607c47f46d47c30267285 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 10 Mar 2023 18:15:06 +0100 Subject: [PATCH 4/4] update cargo.nix --- Cargo.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.nix b/Cargo.nix index 642735cf..e11a9b34 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -32,7 +32,7 @@ args@{ ignoreLockHash, }: let - nixifiedLockHash = "9941a539c374cfd67691e633af6c6a5da9e8badbb7b14159b3ff24a7cf5ddf8a"; + nixifiedLockHash = "0ee5ebe74e19a2d2d3c41b80ed443c93f079f696681902dda4ca659be282d985"; workspaceSrc = if args.workspaceSrc == null then ./. else args.workspaceSrc; currentLockHash = builtins.hashFile "sha256" (workspaceSrc + /Cargo.lock); lockHashIgnored = if ignoreLockHash @@ -1861,6 +1861,9 @@ in devDependencies = { mktemp = (rustPackages."registry+https://github.com/rust-lang/crates.io-index".mktemp."0.5.0" { inherit profileName; }).out; }; + buildDependencies = { + rustc_version = (buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".rustc_version."0.4.0" { profileName = "__noProfile"; }).out; + }; }); "unknown".garage_web."0.8.1" = overridableMkRustCrate (profileName: rec {