Skip to content

Commit b08cce7

Browse files
authored
[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.
1 parent 8592a6b commit b08cce7

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

openapi/nexus.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19805,7 +19805,10 @@
1980519805
"count",
1980619806
"bytes",
1980719807
"seconds",
19808-
"nanoseconds"
19808+
"nanoseconds",
19809+
"volts",
19810+
"amps",
19811+
"degrees_celcius"
1980919812
]
1981019813
},
1981119814
{
@@ -19814,6 +19817,13 @@
1981419817
"enum": [
1981519818
"none"
1981619819
]
19820+
},
19821+
{
19822+
"description": "Rotations per minute.",
19823+
"type": "string",
19824+
"enum": [
19825+
"rpm"
19826+
]
1981719827
}
1981819828
]
1981919829
},

oximeter/impl/src/schema/codegen.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,12 @@ impl quote::ToTokens for Units {
522522
Units::Nanoseconds => {
523523
quote! { ::oximeter::schema::Units::Nanoseconds }
524524
}
525+
Units::Amps => quote! { ::oximeter::schema::Units::Amps },
526+
Units::Volts => quote! { ::oximeter::schema::Units::Volts },
527+
Units::DegreesCelcius => {
528+
quote! { ::oximeter::schema::Units::DegreesCelcius }
529+
}
530+
Units::Rpm => quote! { ::oximeter::schema::Units::Rpm },
525531
};
526532
toks.to_tokens(tokens);
527533
}

oximeter/impl/src/schema/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ pub struct TimeseriesDescription {
179179
/// Measurement units for timeseries samples.
180180
#[derive(Clone, Copy, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
181181
#[serde(rename_all = "snake_case")]
182-
// TODO-completeness: Include more units, such as power / temperature.
183182
// TODO-completeness: Decide whether and how to handle dimensional analysis
184183
// during queries, if needed.
185184
pub enum Units {
@@ -189,6 +188,11 @@ pub enum Units {
189188
Bytes,
190189
Seconds,
191190
Nanoseconds,
191+
Volts,
192+
Amps,
193+
DegreesCelcius,
194+
/// Rotations per minute.
195+
Rpm,
192196
}
193197

194198
/// The schema for a timeseries.

0 commit comments

Comments
 (0)