mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Fix labels comparison, fetch correct labels
This commit is contained in:
parent
ce7f4106c2
commit
cddc29fa17
|
@ -370,6 +370,9 @@ func compareLabels(a, b Labels) int {
|
|||
if d := strings.Compare(a[i].Name, b[i].Name); d != 0 {
|
||||
return d
|
||||
}
|
||||
if d := strings.Compare(a[i].Value, b[i].Value); d != 0 {
|
||||
return d
|
||||
}
|
||||
}
|
||||
// If all labels so far were in common, the set with fewer labels comes first.
|
||||
return len(a) - len(b)
|
||||
|
|
|
@ -211,6 +211,19 @@ func TestCompareLabels(t *testing.T) {
|
|||
b: []Label{{"aa", ""}, {"ab", ""}},
|
||||
res: 1,
|
||||
},
|
||||
{
|
||||
a: []Label{
|
||||
{"__name__", "go_gc_duration_seconds"},
|
||||
{"job", "prometheus"},
|
||||
{"quantile", "0.75"},
|
||||
},
|
||||
b: []Label{
|
||||
{"__name__", "go_gc_duration_seconds"},
|
||||
{"job", "prometheus"},
|
||||
{"quantile", "1"},
|
||||
},
|
||||
res: -1,
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
// Use constructor to ensure sortedness.
|
||||
|
|
|
@ -271,7 +271,7 @@ func (r *indexReader) Series(ref uint32, mint, maxt int64) (Series, error) {
|
|||
// the underlying strings.
|
||||
labels := make(Labels, 0, k)
|
||||
|
||||
for i := 0; i < int(k); i += 2 {
|
||||
for i := 0; i < len(offsets); i += 2 {
|
||||
n, err := r.lookupSymbol(offsets[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "symbol lookup")
|
||||
|
|
Loading…
Reference in a new issue