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
promhttp: Check validity of method and code label values #962
Conversation
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
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.
This is epic! Proposed a more flexible API, otherwise, it's perfect, thanks!
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
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.
LGTM in general, just a few thoughts.
| if len(additionalMethods) > 0 { | ||
| for _, method := range additionalMethods { | ||
| if strings.EqualFold(m, method) { | ||
| return strings.ToLower(m) |
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.
Can't we just use method here instead of m? It wouldn't require ToLower if we documented that additional methods are used with the same capitalization as provided (which some users might even need).
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.
Of course, it's an option. I just respected the previous design decisions here. Everything was the lower case before and just kept it. I'm inclined to keep the lower case behaviour and if someone requests it we can change it; it's a minor one anyways.
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.
LGTM, just a small inconsistency. I would pick shorter name, additional is quite long word to use everywhere and in those case we often say extra, but up to you (:
| if s >= 100 && s <= 599 { | ||
| return strconv.Itoa(s) | ||
| } | ||
| return "unknown" |
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.
(:
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
* Check validity of method and code label values Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com> * Use more flexibly functional option pattern for configuration Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com> * Update documentation Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com> * Simplify Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com> * Fix inconsistent method naming Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
* Check validity of method and code label values Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com> * Use more flexibly functional option pattern for configuration Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com> * Update documentation Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com> * Simplify Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com> * Fix inconsistent method naming Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com> Co-authored-by: Kemal Akkoyun <kakkoyun@users.noreply.github.com>
Signed-off-by: Kemal Akkoyun kakkoyun@gmail.com