mirror of
https://github.com/prometheus/prometheus.git
synced 2025-11-29 06:31:01 +01:00
Add metrics to result after checking all matchers
Should be marginally faster and somewhat more GC friendly
This commit is contained in:
parent
bedc0eda1f
commit
c048a0cde8
@ -631,19 +631,22 @@ func (s *MemorySeriesStorage) metricsForLabelMatchers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
result := map[model.Fingerprint]metric.Metric{}
|
result := map[model.Fingerprint]metric.Metric{}
|
||||||
|
FP_LOOP:
|
||||||
for fp := range remainingFPs {
|
for fp := range remainingFPs {
|
||||||
s.fpLocker.Lock(fp)
|
s.fpLocker.Lock(fp)
|
||||||
if met, _, ok := s.metricForRange(fp, from, through); ok {
|
met, _, ok := s.metricForRange(fp, from, through)
|
||||||
result[fp] = metric.Metric{Metric: met}
|
|
||||||
}
|
|
||||||
s.fpLocker.Unlock(fp)
|
s.fpLocker.Unlock(fp)
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
continue FP_LOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, m := range matchers[matcherIdx:] {
|
for _, m := range matchers[matcherIdx:] {
|
||||||
for fp, met := range result {
|
if !m.Match(met[m.Name]) {
|
||||||
if !m.Match(met.Metric[m.Name]) {
|
continue FP_LOOP
|
||||||
delete(result, fp)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
result[fp] = metric.Metric{Metric: met}
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user