rpc/system_metrics.rs: Added rustversion label to garage_build_info metric. #524

Merged
lx merged 5 commits from jpds/garage:rustversion-label into main 2023-03-13 15:46:49 +00:00
5 changed files with 20 additions and 4 deletions
Showing only changes of commit 25f2a46fc3 - Show all commits

1
Cargo.lock generated
View file

@ -1309,6 +1309,7 @@ dependencies = [
"opentelemetry", "opentelemetry",
"rand", "rand",
"rmp-serde", "rmp-serde",
"rustc_version",
"serde", "serde",
"serde_json", "serde_json",
"sha2 0.10.6", "sha2 0.10.6",

View file

@ -31,10 +31,10 @@ impl SystemMetrics {
.u64_value_observer("garage_build_info", move |observer| { .u64_value_observer("garage_build_info", move |observer| {
observer.observe( observer.observe(
1, 1,
&[KeyValue::new( &[
"version", KeyValue::new("rustversion", garage_util::version::rust_version()),
garage_util::version::garage_version(), KeyValue::new("version", garage_util::version::garage_version()),
)], ],
) )
}) })
.with_description("Garage build info") .with_description("Garage build info")

View file

@ -47,6 +47,9 @@ hyper = "0.14"
opentelemetry = { version = "0.17", features = [ "rt-tokio", "metrics", "trace" ] } opentelemetry = { version = "0.17", features = [ "rt-tokio", "metrics", "trace" ] }
[build-dependencies]
rustc_version = "0.4.0"
[dev-dependencies] [dev-dependencies]
mktemp = "0.5" mktemp = "0.5"

8
src/util/build.rs Normal file
View file

@ -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}");
}

View file

@ -26,3 +26,7 @@ pub fn init_version(version: &'static str) {
pub fn init_features(features: &'static [&'static str]) { pub fn init_features(features: &'static [&'static str]) {
FEATURES.store(Some(Arc::new(features))); FEATURES.store(Some(Arc::new(features)));
} }
pub fn rust_version() -> &'static str {
env!("RUSTC_VERSION")
}