Skip to content

Commit

Permalink
feat: data/histogram: add TransformBinNamesExactMatch()
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed May 27, 2021
1 parent 908b4d5 commit 75f810e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions data/histogram/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ func TransformBinNames(hist *Histogram, xfFunc func(input string) string) *Histo
return newHist
}

// TransformBinNamesExactMatch modifies bin names and returns a new
// histogram.
func TransformBinNamesExactMatch(hist *Histogram, xfMap map[string]string) *Histogram {
if hist == nil {
return nil
}
return TransformBinNames(hist,
func(oldName string) string {
for oldNameTry, newName := range xfMap {
if oldNameTry == oldName {
return newName
}
}
return oldName
},
)
}

// TransformBinNamesByPrefix modifies bin names and returns a new
// histogram.
func TransformBinNamesByPrefix(hist *Histogram, xfMap map[string]string) *Histogram {
Expand Down

0 comments on commit 75f810e

Please sign in to comment.