Improve tailer matcher function. (#2959)

Don't create a map on every new push of a stream or appearance of a new stream.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
pull/2960/head
Cyril Tovena 5 years ago committed by GitHub
parent 4da505b413
commit a62f81f1cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      pkg/ingester/stream.go
  2. 5
      pkg/ingester/tailer.go

@ -310,6 +310,5 @@ func (s *stream) addTailer(t *tailer) {
}
func (s *stream) matchesTailer(t *tailer) bool {
metric := util.LabelsToMetric(s.labels)
return t.isWatchingLabels(metric)
return t.isWatchingLabels(s.labels)
}

@ -8,7 +8,6 @@ import (
cortex_util "github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"golang.org/x/net/context"
@ -183,9 +182,9 @@ func (t *tailer) processStream(stream logproto.Stream) ([]logproto.Stream, error
}
// Returns true if tailer is interested in the passed labelset
func (t *tailer) isWatchingLabels(metric model.Metric) bool {
func (t *tailer) isWatchingLabels(lbs labels.Labels) bool {
for _, matcher := range t.matchers {
if !matcher.Matches(string(metric[model.LabelName(matcher.Name)])) {
if !matcher.Matches(lbs.Get(matcher.Name)) {
return false
}
}

Loading…
Cancel
Save