diff options
author | Jonathan Davies <jpds@protonmail.com> | 2023-03-10 11:40:58 +0000 |
---|---|---|
committer | Jonathan Davies <jpds@protonmail.com> | 2023-03-10 14:46:44 +0000 |
commit | 25f2a46fc3e50c882cd518244bb49d44d01ca442 (patch) | |
tree | 7842b8880eb26171e2abeb98ed8111814708e141 /src | |
parent | 9e061d5a70f35db7c62c79089567ef4dc226e413 (diff) | |
download | garage-25f2a46fc3e50c882cd518244bb49d44d01ca442.tar.gz garage-25f2a46fc3e50c882cd518244bb49d44d01ca442.zip |
rpc/system_metrics.rs: Added rustversion label to garage_build_info metric.
Diffstat (limited to 'src')
-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 |
4 files changed, 19 insertions, 4 deletions
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") +} |