Update prometheus methods
This commit is contained in:
parent
9766ad8f4b
commit
55ccaf4be3
2 changed files with 22 additions and 3 deletions
|
|
@ -137,8 +137,8 @@ func (s metricSorter) Swap(i, j int) {
|
|||
}
|
||||
|
||||
func (s metricSorter) Less(i, j int) bool {
|
||||
sort.Sort(prometheus.LabelPairSorter(s[i].Label))
|
||||
sort.Sort(prometheus.LabelPairSorter(s[j].Label))
|
||||
sort.Sort(labelPairSorter(s[i].Label))
|
||||
sort.Sort(labelPairSorter(s[j].Label))
|
||||
|
||||
if len(s[i].Label) != len(s[j].Label) {
|
||||
return len(s[i].Label) < len(s[j].Label)
|
||||
|
|
@ -181,3 +181,19 @@ func normalizeMetricFamilies(metricFamiliesByName map[string]*dto.MetricFamily)
|
|||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// labelPairSorter implements sort.Interface. It is used to sort a slice of
|
||||
// dto.LabelPair pointers.
|
||||
type labelPairSorter []*dto.LabelPair
|
||||
|
||||
func (s labelPairSorter) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s labelPairSorter) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
||||
func (s labelPairSorter) Less(i, j int) bool {
|
||||
return s[i].GetName() < s[j].GetName()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue