Merge pull request #180 from dnesting/dnesting-sort-metrics
Make metric sort stable and sort by timestamp
This commit is contained in:
commit
cfd904193d
|
@ -722,5 +722,18 @@ func (s metricSorter) Less(i, j int) bool {
|
|||
return vi < vj
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
||||
// We should never arrive here. Multiple metrics with the same
|
||||
// label set in the same scrape will lead to undefined ingestion
|
||||
// behavior. However, as above, we have to provide stable sorting
|
||||
// here, even for inconsistent metrics. So sort equal metrics
|
||||
// by their timestamp, with missing timestamps (implying "now")
|
||||
// coming last.
|
||||
if s[i].TimestampMs == nil {
|
||||
return false
|
||||
}
|
||||
if s[j].TimestampMs == nil {
|
||||
return true
|
||||
}
|
||||
return s[i].GetTimestampMs() < s[j].GetTimestampMs()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue