-
Notifications
You must be signed in to change notification settings - Fork 149
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
Validate label names #236
Validate label names #236
Conversation
9c4ff92
to
b06f8e7
Compare
|
||
unless key.to_s =~ LABEL_NAME_REGEX | ||
msg = "label name must match /#{LABEL_NAME_REGEX}/" | ||
raise InvalidLabelError, msg |
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.
Does rubocop complain if we inline this msg
?
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.
No, in the sense that we don't run rubocop on this project. I think I must have wanted a shorter line, but I'm happy to change 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.
I'd inline it, for readability. The separate var had me scanning the code for where else we use it
Looks like a regex replacement was run against this file and was a little too eager. Signed-off-by: Chris Sinjakli <chris@sinjakli.co.uk>
1efd685
to
3fc686d
Compare
Up to now, we've only been performing limited validation of label names. This commit validates that the characters use match the regex `/\A[a-zA-Z_][a-zA-Z0-9_]*\Z/` as specified by: https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels Signed-off-by: Chris Sinjakli <chris@sinjakli.co.uk>
3fc686d
to
3519342
Compare
Up to now, we've only been performing limited validation of label names.
This commit validates that the characters use match the regex
/\A[a-zA-Z_][a-zA-Z0-9_]*\Z/
as specified by:https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
I ran into this while working on #234 for #186, but thought I'd separate it out into its own PR.
It's technically a breaking change, but I can't imagine Prometheus would have been happy scraping labels with these names to begin with. On top of that, our master branch already has breaking changes on it for the 3.0 release, so I figure one more doesn't hurt.