aboutsummaryrefslogtreecommitdiff
path: root/src/util
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 /src/util
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
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Cargo.toml3
-rw-r--r--src/util/build.rs8
-rw-r--r--src/util/version.rs4
3 files changed, 15 insertions, 0 deletions
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")
+}