aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2023-03-13 15:46:48 +0000
committerAlex <alex@adnab.me>2023-03-13 15:46:48 +0000
commit7fcc153e7cfbae61626ca288634a0f4fb4c4b709 (patch)
treeaa39b41d63358277d61f2cb92ef9565a97c1c901
parentdc6be3983300ee3ee10f601cfc04a06563d86f48 (diff)
parentf37ec584b6009b16d1c7f06918889954b22f5afb (diff)
downloadgarage-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
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.nix5
-rw-r--r--src/api/admin/cluster.rs2
-rw-r--r--src/garage/admin.rs3
-rw-r--r--src/rpc/system_metrics.rs8
-rw-r--r--src/util/Cargo.toml3
-rw-r--r--src/util/build.rs8
-rw-r--r--src/util/version.rs4
8 files changed, 28 insertions, 6 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4d0e1534..a27274a5 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/Cargo.nix b/Cargo.nix
index 69274c07..a67751dd 100644
--- a/Cargo.nix
+++ b/Cargo.nix
@@ -32,7 +32,7 @@ args@{
ignoreLockHash,
}:
let
- nixifiedLockHash = "12ff12e9210c87ac93e2f2bdb7007b6232e7efcfa302c272bf0caee6e78abd10";
+ nixifiedLockHash = "d36a8590fdf6eeb128a5a852d55945b595d5830291ad0aca95a21dcc1fab8681";
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 {
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")
+}