From b08cce78804c94e19a8404d58beafa3d6d296d4a Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Tue, 13 Aug 2024 09:20:46 -0700 Subject: [PATCH] [oximeter] Add some units from physical reality (#6296) In service of future changes to record data from power, temperature, and fan speed sensors in Oximeter, this branch adds some physical quantities to the `Units` enum: `Volts`, `Amps`, `DegreesCelcius`, and `Rpm`. I've added all of these as whole numbers of the measured quantities, with the expectation that they will probably be recorded as floating-point. We could consider instead using a smaller unit like `MilliAmps`, and recording them as integers, but that introduces a bunch of dimensional analysis that I'm not sure if we want to be doing. --- openapi/nexus.json | 12 +++++++++++- oximeter/impl/src/schema/codegen.rs | 6 ++++++ oximeter/impl/src/schema/mod.rs | 6 +++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/openapi/nexus.json b/openapi/nexus.json index ae5eaeae64..da77eec2a8 100644 --- a/openapi/nexus.json +++ b/openapi/nexus.json @@ -19805,7 +19805,10 @@ "count", "bytes", "seconds", - "nanoseconds" + "nanoseconds", + "volts", + "amps", + "degrees_celcius" ] }, { @@ -19814,6 +19817,13 @@ "enum": [ "none" ] + }, + { + "description": "Rotations per minute.", + "type": "string", + "enum": [ + "rpm" + ] } ] }, diff --git a/oximeter/impl/src/schema/codegen.rs b/oximeter/impl/src/schema/codegen.rs index d433441718..4778cf4970 100644 --- a/oximeter/impl/src/schema/codegen.rs +++ b/oximeter/impl/src/schema/codegen.rs @@ -522,6 +522,12 @@ impl quote::ToTokens for Units { Units::Nanoseconds => { quote! { ::oximeter::schema::Units::Nanoseconds } } + Units::Amps => quote! { ::oximeter::schema::Units::Amps }, + Units::Volts => quote! { ::oximeter::schema::Units::Volts }, + Units::DegreesCelcius => { + quote! { ::oximeter::schema::Units::DegreesCelcius } + } + Units::Rpm => quote! { ::oximeter::schema::Units::Rpm }, }; toks.to_tokens(tokens); } diff --git a/oximeter/impl/src/schema/mod.rs b/oximeter/impl/src/schema/mod.rs index 7743034e31..250604d7be 100644 --- a/oximeter/impl/src/schema/mod.rs +++ b/oximeter/impl/src/schema/mod.rs @@ -179,7 +179,6 @@ pub struct TimeseriesDescription { /// Measurement units for timeseries samples. #[derive(Clone, Copy, Debug, Deserialize, Serialize, JsonSchema, PartialEq)] #[serde(rename_all = "snake_case")] -// TODO-completeness: Include more units, such as power / temperature. // TODO-completeness: Decide whether and how to handle dimensional analysis // during queries, if needed. pub enum Units { @@ -189,6 +188,11 @@ pub enum Units { Bytes, Seconds, Nanoseconds, + Volts, + Amps, + DegreesCelcius, + /// Rotations per minute. + Rpm, } /// The schema for a timeseries.