Skip to content

Commit

Permalink
[oximeter] Add some units from physical reality (#6296)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hawkw authored Aug 13, 2024
1 parent 8592a6b commit b08cce7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -19805,7 +19805,10 @@
"count",
"bytes",
"seconds",
"nanoseconds"
"nanoseconds",
"volts",
"amps",
"degrees_celcius"
]
},
{
Expand All @@ -19814,6 +19817,13 @@
"enum": [
"none"
]
},
{
"description": "Rotations per minute.",
"type": "string",
"enum": [
"rpm"
]
}
]
},
Expand Down
6 changes: 6 additions & 0 deletions oximeter/impl/src/schema/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 5 additions & 1 deletion oximeter/impl/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -189,6 +188,11 @@ pub enum Units {
Bytes,
Seconds,
Nanoseconds,
Volts,
Amps,
DegreesCelcius,
/// Rotations per minute.
Rpm,
}

/// The schema for a timeseries.
Expand Down

0 comments on commit b08cce7

Please sign in to comment.