diff --git a/pkg/logproto/compat.go b/pkg/logproto/compat.go index b248a352c950..fc89fcc993c9 100644 --- a/pkg/logproto/compat.go +++ b/pkg/logproto/compat.go @@ -356,11 +356,13 @@ func (m *FilterChunkRefRequest) GetStep() int64 { // GetQuery returns the query of the request. // The query is the hash for the input chunks refs and the filter expressions. func (m *FilterChunkRefRequest) GetQuery() string { + var encodeBuf []byte var chunksHash uint64 if len(m.Refs) > 0 { h := xxhash.New() for _, ref := range m.Refs { - _, _ = h.WriteString(fmt.Sprintf("%s-%d", ref.Tenant, ref.Fingerprint)) + encodeBuf = encodeBuf[:0] + _, _ = h.Write(fmt.Appendf(encodeBuf, "%d", ref.Fingerprint)) } chunksHash = h.Sum64() } @@ -375,7 +377,8 @@ func (m *FilterChunkRefRequest) GetQuery() string { if i > 0 { sb.WriteString(",") } - sb.WriteString(strconv.Itoa(int(filter.Operator))) + encodeBuf = encodeBuf[:0] + sb.WriteString(string(fmt.Appendf(encodeBuf, "%d", filter.Operator))) sb.WriteString("-") sb.WriteString(filter.Match) } diff --git a/pkg/logproto/compat_test.go b/pkg/logproto/compat_test.go index b0b87f2014ca..0223e9f25b23 100644 --- a/pkg/logproto/compat_test.go +++ b/pkg/logproto/compat_test.go @@ -298,7 +298,7 @@ func TestFilterChunkRefRequestGetQuery(t *testing.T) { }, }, }, - expected: `10379275979514026197`, + expected: `13237225503670494420`, }, { desc: "request with filters but no chunks", @@ -336,7 +336,7 @@ func TestFilterChunkRefRequestGetQuery(t *testing.T) { }, }, }, - expected: `8320232433975427174/0-uuid,1-trace`, + expected: `6080128442901703586/0-uuid,1-trace`, }, } { t.Run(tc.desc, func(t *testing.T) {