Skip to content
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

Default Instrument unit does not comply with spec #2910

Closed
Tracked by #2574 ...
pichlermarc opened this issue Apr 19, 2022 · 5 comments · Fixed by #2983
Closed
Tracked by #2574 ...

Default Instrument unit does not comply with spec #2910

pichlermarc opened this issue Apr 19, 2022 · 5 comments · Fixed by #2983
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@pichlermarc
Copy link
Member

Currently the spec states here that:

If the unit is not provided or the unit is null, the API and SDK MUST make sure that the behavior is the same as an empty unit string.

However, the current implementation does change undefined and null units to '1' in createInstrumentDescriptor(), which is different from the empty string. An empty string is usually kept.

The Metrics API and SDK specs does not define a "default" unit, therefore to make this compliant with the spec we have two options:

  1. treat empty strings as '1'
  2. treat null and undefined as an empty string.

I think the spec allows for these two options so it might also make sense to ask for clarification in the spec repo.

@pichlermarc pichlermarc added the bug Something isn't working label Apr 19, 2022
@pichlermarc pichlermarc changed the title Instrument unit does not comply with spec Default Instrument unit does not comply with spec Apr 19, 2022
@dyladan
Copy link
Member

dyladan commented Apr 19, 2022

Hmm that's an interesting one. AFAIK the "default unit" was '1' at one point, which is probably why null/undefined was transformed to '1'. Empty string not being transformed seems like a reasonable behavior as well because a user specifically included a string. Reading the spec I think we should treat null/undefined as empty string and not transform to '1'

@pichlermarc
Copy link
Member Author

+1 for treating null/undefined as an empty string. This allows backends to distinguish between a truely undefined unit and '1' being used on purpose. 🙂

This sounds like a candidate for "good first issue". 🙂

@dyladan dyladan added good first issue Good for newcomers up-for-grabs Good for taking. Extra help will be provided by maintainers labels Apr 20, 2022
@andyfleming
Copy link
Contributor

I'll tackle this 👍

@dyladan dyladan removed the up-for-grabs Good for taking. Extra help will be provided by maintainers label Apr 20, 2022
@dyladan
Copy link
Member

dyladan commented May 11, 2022

@andyfleming any update on this?

@andyfleming
Copy link
Contributor

Getting back to this now. Opened up a PR. There's an outstanding issue, but we can continue that discussion over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment