Skip to content

Commit

Permalink
Fix #512
Browse files Browse the repository at this point in the history
Signed-off-by: beorn7 <[email protected]>
  • Loading branch information
beorn7 committed Dec 6, 2018
1 parent 9542e40 commit fae8896
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion prometheus/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,13 @@ func checkMetricConsistency(
h = hashAddByte(h, separatorByte)
// Make sure label pairs are sorted. We depend on it for the consistency
// check.
sort.Sort(labelPairSorter(dtoMetric.Label))
if !sort.IsSorted(labelPairSorter(dtoMetric.Label)) {
// We cannot sort dtoMetric.Label in place as it is immutable by contract.
copiedLabels := make([]*dto.LabelPair, len(dtoMetric.Label))
copy(copiedLabels, dtoMetric.Label)
sort.Sort(labelPairSorter(copiedLabels))
dtoMetric.Label = copiedLabels
}
for _, lp := range dtoMetric.Label {
h = hashAdd(h, lp.GetName())
h = hashAddByte(h, separatorByte)
Expand Down

0 comments on commit fae8896

Please sign in to comment.