-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The design of metrics::Unit #360
Comments
For the internally handled option, I would expect, at least:
|
My gut instinct is that the only baked-in unit names/prefixes should be the ones that While obviously there's a lot of real unit values that are standardized -- length, mass, energy, force, yadda yadda yadda -- they're by and large the exception to how Coupled with the notion of |
You are right that with the Another option I can see is to keep units internal, but since adding new ones will most likely end up near-trivial just encourage PRs, for when someone can't stand using the The one thing about using an external crate is, best I can tell, all three crates I found focus on expressing quantities with a unit, not units themselves. It's a subtle distinction, but one which might make them not really suitable for use with You did not address splitting the unit and the prefix - can I take it as a tacit agreement? While similar to units themselves, the set is much smaller - at first I'd suggest adopting at least a part of metric prefixes and all eight binary IEC prefixes. For representing actual numerical values of the prefixes, it's probably best to use |
I generally agree with that aspect, yes. As an aside, one area where unit and prefix living side-by-side sort of falls down is with temperature: millicelsius or kilofahrenheit isn't exactly a thing in practice, even if you could theoretically determine that "1.48 degrees kilofahrenheit" is just 1,480 degrees fahrenheit. Like, it's technically correct, no question, but it would definitely be weird. I guess this implies we might need to make prefix either optional or have a |
Good catch - a As an aside, I've heard people use "megadollars" in casual conversations. |
metrics::Unit is missing multiple unit strings supported by CloudWatch Embedded Metrics: |
Why?
In #337 @tobz asks:
And it's most definitely not: off the top of my mind, it's missing temperature, voltage, electric current, power - just to name a few used to monitor computer hardware.
And while yes,
metrics
is probably intended mostly as a library to measure the performance of software, if it gets popular enough at some point it will inevitably be used with more physical quantities.Hence, this issue, because the current design of
metrics::Unit
is definitely not satisfactory.Questions to answer?
There are two questions to answer here:
metrics
deal with units at all? Or just pass them through?Possible designs
Just plain strings
There's so many units of measurement that simply passing them through is a very tempting option. So much so that the current implementation of OpenTelemetry protocol does exactly this.
Internally
Another option is to have some enumeration in
metrics
itself, with an escape hatch for more unusual units. This would still be a decently large undertatking. A quick estimate is that just the SI system has around a hundred different units.A quick sketch of an API would be something like below, with the understanding that
UnitName
,UnitPrefix
andUnit
all implementDisplay
, or a similar trait, to allow Recorders to easily convert the units to, at least, aShardString
.Use an external crate
Option I admittedly have not looked much into, use an existing crate to deal with this. A few I found with a quick search:
dimensioned
uom
simple_si_units
The text was updated successfully, but these errors were encountered: