diff --git a/CHANGELOG.md b/CHANGELOG.md index 711fdb69ae2..0d23dba25fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re ### Fixed - [#5502](https://github.com/thanos-io/thanos/pull/5502) Receive: Handle exemplar storage errors as conflict error. - [#5534](https://github.com/thanos-io/thanos/pull/5534) Query: Set struct return by query api alerts same as prometheus api. -- [#5554](https://github.com/thanos-io/thanos/pull/5534) Query/Receiver: Fix querying exemplars from multi-tenant receivers. +- [#5554](https://github.com/thanos-io/thanos/pull/5554) Query/Receiver: Fix querying exemplars from multi-tenant receivers. ### Added diff --git a/pkg/exemplars/proxy.go b/pkg/exemplars/proxy.go index 0b9cfc45e12..0e4903ebaea 100644 --- a/pkg/exemplars/proxy.go +++ b/pkg/exemplars/proxy.go @@ -80,8 +80,10 @@ func (s *Proxy) Exemplars(req *exemplarspb.ExemplarsRequest, srv exemplarspb.Exe exemplars []*exemplarspb.ExemplarData ) + queryParts := make([]string, 0) + labelMatchers := make([]string, 0) for _, st := range s.exemplars() { - var queryParts []string + queryParts = queryParts[:0] Matchers: for _, matchers := range selectors { @@ -102,12 +104,12 @@ func (s *Proxy) Exemplars(req *exemplarspb.ExemplarsRequest, srv exemplarspb.Exe } } - matchers := make([]string, 0, len(matcherSet)) + labelMatchers = labelMatchers[:0] for m := range matcherSet { - matchers = append(matchers, m) + labelMatchers = append(labelMatchers, m) } - queryParts = append(queryParts, "{"+strings.Join(matchers, ", ")+"}") + queryParts = append(queryParts, "{"+strings.Join(labelMatchers, ", ")+"}") } // No matchers match this store. diff --git a/pkg/exemplars/proxy_test.go b/pkg/exemplars/proxy_test.go index 08b18d9f02d..bd52689b748 100644 --- a/pkg/exemplars/proxy_test.go +++ b/pkg/exemplars/proxy_test.go @@ -12,16 +12,16 @@ import ( "sync" "testing" - "github.com/prometheus/prometheus/promql/parser" + "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "go.uber.org/atomic" + "github.com/go-kit/log" "github.com/pkg/errors" "github.com/prometheus/prometheus/model/labels" - "go.uber.org/atomic" - "google.golang.org/grpc" - + "github.com/prometheus/prometheus/promql/parser" "github.com/thanos-io/thanos/pkg/exemplars/exemplarspb" "github.com/thanos-io/thanos/pkg/store/labelpb" "github.com/thanos-io/thanos/pkg/store/storepb"