chore: allow dashes and dots in the metric label values#267
chore: allow dashes and dots in the metric label values#267IuryAlves wants to merge 1 commit intouber-go:masterfrom
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.
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
DefaultSanitizerOptsto 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
SanitizeRangeis 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 theCharactersfield 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