Skip to content

Commit

Permalink
Fix special case when normalizing label metric names
Browse files Browse the repository at this point in the history
  • Loading branch information
frodenas committed Jul 7, 2017
1 parent 6a978c8 commit ec9e1d1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion utils/normalize_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NormalizeName(name string) string {

words := camelcase.Split(name)
for _, word := range words {
safeWord := strings.Trim(safeNameRE.ReplaceAllLiteralString(word, "_"), "_")
safeWord := strings.Trim(safeNameRE.ReplaceAllLiteralString(strings.Trim(word, "_"), "_"), "_")
lowerWord := strings.TrimSpace(strings.ToLower(safeWord))
if lowerWord != "" {
normalizedName = append(normalizedName, lowerWord)
Expand Down
2 changes: 1 addition & 1 deletion utils/normalize_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

var _ = Describe("NormalizeName", func() {
It("normalizes a name", func() {
Expect(NormalizeName("This_is__a-MetricName.Example/with:0totals")).To(Equal("this_is_a_metric_name_example_with_0_totals"))
Expect(NormalizeName("This_is_-_a-MetricName.Example/with:0totals")).To(Equal("this_is_a_metric_name_example_with_0_totals"))
})
})

Expand Down

0 comments on commit ec9e1d1

Please sign in to comment.