-
Notifications
You must be signed in to change notification settings - Fork 123
chore: allow dashes and dots in the metric label values #267
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
base: master
Are you sure you want to change the base?
chore: allow dashes and dots in the metric label values #267
Conversation
The Prometheus Data model allows any unicode characters in label values, as documented [here](https://prometheus.io/docs/concepts/data_model/\#:\~:text\=Label%20values%20may%20contain%20any%20Unicode%20characters.)
WalkthroughThe update modifies the sanitization options in the Prometheus module. In the Changes
Sequence Diagram(s)(No sequence diagram is provided as the changes involve a configuration update without modifications to control flow.) Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
prometheus/sanitize.go (1)
38-38
: Aligns with PR objective of allowing dashes and dots in metric label values.This change correctly modifies the
DefaultSanitizerOpts
to allow dashes-
and dots.
in metric label values by appending them to the existingAlphanumericRange
. This aligns with the Prometheus data model as mentioned in the PR objectives.However, I notice that
SanitizeRange
is typically used for character ranges (like 'a' to 'z'), but here it's being used for individual characters. While this works, it might be worth considering whether these characters should be added to theCharacters
field instead for better semantic clarity, especially since they're not a continuous range.var DefaultSanitizerOpts = tally.SanitizeOptions{ NameCharacters: tally.ValidCharacters{ Ranges: tally.AlphanumericRange, Characters: tally.UnderscoreCharacters, }, KeyCharacters: tally.ValidCharacters{ Ranges: tally.AlphanumericRange, Characters: tally.UnderscoreCharacters, }, ValueCharacters: tally.ValidCharacters{ - Ranges: append(tally.AlphanumericRange, tally.SanitizeRange{rune('-'), rune('.')}), + Ranges: tally.AlphanumericRange, + Characters: append(tally.UnderscoreCharacters, []rune{'-', '.'}...), Characters: tally.UnderscoreCharacters, }, ReplacementCharacter: tally.DefaultReplacementCharacter, }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
prometheus/sanitize.go
(1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
prometheus/sanitize.go (1)
sanitize.go (2)
AlphanumericRange
(34-37)SanitizeRange
(61-61)
The Prometheus Data model allows any unicode characters in label values, as documented here
Summary by CodeRabbit