mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08: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{}
|
||||
FP_LOOP:
|
||||
for fp := range remainingFPs {
|
||||
s.fpLocker.Lock(fp)
|
||||
if met, _, ok := s.metricForRange(fp, from, through); ok {
|
||||
result[fp] = metric.Metric{Metric: met}
|
||||
}
|
||||
met, _, ok := s.metricForRange(fp, from, through)
|
||||
s.fpLocker.Unlock(fp)
|
||||
}
|
||||
for _, m := range matchers[matcherIdx:] {
|
||||
for fp, met := range result {
|
||||
if !m.Match(met.Metric[m.Name]) {
|
||||
delete(result, fp)
|
||||
|
||||
if !ok {
|
||||
continue FP_LOOP
|
||||
}
|
||||
|
||||
for _, m := range matchers[matcherIdx:] {
|
||||
if !m.Match(met[m.Name]) {
|
||||
continue FP_LOOP
|
||||
}
|
||||
}
|
||||
result[fp] = metric.Metric{Metric: met}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue