-
Notifications
You must be signed in to change notification settings - Fork 34
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
Metrics: creating tags with fallback value #152
Conversation
Will give @nmiyake a chance to take a look but we'll get a release out soon |
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.
Reviewed 1 of 1 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @asanderson15)
metrics/tag.go, line 80 at r2 (raw file):
// NewTagWithFallbackValue returns the result of calling NewTag, and if that fails, calls MustNewTag with a fallback // value. Note: because MustNewTag will panic if it fails, both the key and fallback value must be known to be valid.
Let's expand this comment to describe the intended use case:
This function is useful when value is provided as a runtime input and the desired behavior is to fall back to use a known valid value (for example, "unknown") when the value is invalid.
Sorry for dragging on this -- it's because this PR exists in the zone where I don't love adding it to the API, but understand the current pain/code duplication and can't say that it doesn't make sense to add out-right :) At the end of the day, I don't see a major down-side to adding this, so OK with it on the whole. Left some feedback on preference to update the documentation a bit, but otherwise I'm good with this. |
No problem @nmiyake. That all makes sense. Agree with the comment and added the add'l docs. |
We frequently want to create a tag with a known key, but potentially invalid value, in which case we want to fall back to a known value such as the string
unknown
. This allows us to do so without repeatedly rewriting the same fallback code.This change is