Skip to content

Commit

Permalink
[oximeter] Add some units from physical reality
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 committed Aug 12, 2024
1 parent 90d4b2a commit 61972f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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 61972f2

Please sign in to comment.