We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9542e40 commit fae8896Copy full SHA for fae8896
prometheus/registry.go
@@ -872,7 +872,13 @@ func checkMetricConsistency(
872
h = hashAddByte(h, separatorByte)
873
// Make sure label pairs are sorted. We depend on it for the consistency
874
// check.
875
- sort.Sort(labelPairSorter(dtoMetric.Label))
+ if !sort.IsSorted(labelPairSorter(dtoMetric.Label)) {
876
+ // We cannot sort dtoMetric.Label in place as it is immutable by contract.
877
+ copiedLabels := make([]*dto.LabelPair, len(dtoMetric.Label))
878
+ copy(copiedLabels, dtoMetric.Label)
879
+ sort.Sort(labelPairSorter(copiedLabels))
880
+ dtoMetric.Label = copiedLabels
881
+ }
882
for _, lp := range dtoMetric.Label {
883
h = hashAdd(h, lp.GetName())
884
0 commit comments