-
Notifications
You must be signed in to change notification settings - Fork 895
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
Add specification of metric instrument units #1177
Conversation
Implementors may choose the correct prefix to use for the scale of values being | ||
measured. The choice of prefix may affect the value type to be recorded. | ||
|
||
> Example: it may be reasonable to record time as an integer when using an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aabmass - I didn't see your comment on #705 before I wrote this up. I'd love your feedback about the wording of this section. How can we add the guidance you were suggesting (if the values to be recorded are whole numbers, instrumenters should prefer recording in a smaller unit (like nanoseconds) rather than recording a floating point in a larger unit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if others think this is a good idea in the first place. The reason I suggested it is:
- Higher precision
- Potentially smaller on wire if we ever switched OTLP to varint
However, Prometheus recommends base units (seconds) and statsd uses milliseconds for time. Is the gain in precision worth it over sticking to prior art? There is also a concern of overflow for very large values, but I can't think of an actual example that would overflow.
specification/metrics/api.md
Outdated
|
||
Metric instruments SHOULD NOT validate that the unit string passed to them is a | ||
valid value. The default unit to be used by a metric instrument when unit is not | ||
provided SHOULD be the non-annotated unity unit (that is: `1`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry a bit about the use of units jargon that may be lost on our readers. On the other hand, I want to embrace it. We should introduce terms to explain the syntax, like "{thing}" is a unity unit counting a quanity of things, to start with, so that a non-annotated unity unit is what you get when all you know is "quantity of things".
Also in the UCUM document, the terms "metric" vs "nonmetric". I'm afraid we also use the term "metric", so this overloading can be confusing, but it's also quite handy.
Some of the lingering confusion about the choice between ValueRecorder/ValueObserver (a.k.a. "Grouping" instruments) vs the others (a.k.a. "Adding" instruments) can be reflected in terms used in the UCUM document.
For example,
Furthermore, for a unit to be metric it must be a quantity on a ratio scale where multiplication and division with scalars are defined.
I think we can say you SHOULD NOT use a nonmetric unit with an Adding instrument.
Those symbols that are used as units that imply a measurement on a scale other than a ratio scale (e.g., interval scale, logarithmic scale) are defined differently. These do not represent proper units as elements of the group (U,·). Therefore those special semantic entities are called special units, as opposed to proper units.
We could say that ValueRecorder/ValueObserver may be used with metric and nonmetric units, on the other hand, and the API has no way to say which it is. We might say that when you use a Grouping instrument for inputs with known-proper units, we can always correctly aggregate these using a sum (because they are "metric"). The SDK can automatically switch between sum and histogram aggregation when units are proper.
Just encouraging you to add a bit more , if you're up to it. 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, after giving this some thought, I think I'm in favor of less jargon.
- I want to remove the term Unity. In the semantic convention table, I'd prefer we use the name
none
, to indicate that this is an instrument measuring something unitless. - I don't love the idea of introducing a new definition of the term metric. In this case, it means a unit that can be meaningfully scaled, especially by orders of magnitude. (They bring up the example that celsius is not metric, even though the SI allows metric prefixes to be used with it, because, for example, 30 celsius is not 3 times hotter than 10 celsius.) This definition is so enormously different from those used elsewhere in the spec, I think it's inviting misunderstanding.
- While I could certainly see the convenience of an SDK choosing the appropriate aggregator based on the units of the instrument, I fear that it's putting too much meaning into a value that I don't think the SDK should need to reason about. There is a lot of meaning that our SDKs could parse out of the units field, but it's a slippery slope. This is part of why this PR took me so long to write -- I kept adding a whole bunch of complexity, then I'd have to scale it back and delete a bunch of paragraphs.
- Having said all that, I would be in favor of adding guidance about what sort of units to use with adding or grouping instruments; I think that would be useful. I'll try putting something like that together today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "identity unit"? "unitless unit"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I think I prefer unitless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with unitless for now. I'm open to more feedback about it. Naming things is hard.
Hey, anyone who's interested in seeing this PR merged, I'd love to get my build-tools PR reviewed. It generates markdown and code for these units. Find it here: open-telemetry/build-tools#21 |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
@justinfoote and @jmacd, I'm commenting here to avoid having this PR closed by the bot. 🤖 |
specification/metrics/api.md
Outdated
| operations | operations | {operations} | | ||
| packets | packets | {packets} | | ||
| processes | processes | {processes} | | ||
| threads | threads | {threads} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it make sense to put these into some yaml so the could be auto-generated to support them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(as a TODO?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 There is a corresponding PR here: open-telemetry/build-tools#21
I had considered adding the yaml to this PR according to that proposal, but I thought it more prudent to wait until that PR merges. It's looking like that's imminent, so maybe I'll go ahead and add the yaml now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the yaml and the generated markdown table in 6fe5382.
This introduces a hard dependency between these PRs though. We can't merge this one until the build-tools one is merged.
specification/metrics/api.md
Outdated
|
||
Metric instruments SHOULD NOT validate that the unit string passed to them is a | ||
valid value. The default unit to be used by a metric instrument when unit is not | ||
provided SHOULD be the non-annotated unity unit (that is: `1`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "identity unit"? "unitless unit"?
In an effort to reduce the unit-related jargon introduced in this part of the spec.
257c961
to
09a4a61
Compare
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @justinfoote
@open-telemetry/specs-metrics-approvers please review. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
@jmacd @justinfoote @open-telemetry/specs-metrics-approvers Was it intended to close this PR? |
@weyert I ❤️ this PR and want to get it approved. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
In the context of open-telemetry/build-tools#65, this came up again. Do you still plan to merge this? If so, would someone care to update the generator docs to document this "unit" feature? |
Fixes #705
Changes
This PR adds some requirements about units for Metric Instruments.
I made some decisions that I'd love feedback on: