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

Metrics: creating tags with fallback value #152

Merged
merged 4 commits into from
Mar 18, 2019

Conversation

asanderson15
Copy link
Contributor

@asanderson15 asanderson15 commented Mar 18, 2019

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 Reviewable

metrics/tag.go Outdated Show resolved Hide resolved
@bmoylan
Copy link
Contributor

bmoylan commented Mar 18, 2019

Will give @nmiyake a chance to take a look but we'll get a release out soon

Copy link
Contributor

@nmiyake nmiyake left a 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.

@nmiyake
Copy link
Contributor

nmiyake commented Mar 18, 2019

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.

@asanderson15
Copy link
Contributor Author

No problem @nmiyake. That all makes sense. Agree with the comment and added the add'l docs.

@bmoylan bmoylan merged commit 0ea410e into palantir:master Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants