Skip to content

Commit a7e3cc8

Browse files
committed
Addressed review feedback
Signed-off-by: Marco Pracucci <[email protected]>
1 parent 6307206 commit a7e3cc8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

pkg/distributor/query.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ func (d *Distributor) queryIngesters(ctx context.Context, replicationSet ring.Re
187187
// queryIngesterStream queries the ingesters using the new streaming API.
188188
func (d *Distributor) queryIngesterStream(ctx context.Context, userID string, replicationSet ring.ReplicationSet, req *ingester_client.QueryRequest) (*ingester_client.QueryStreamResponse, error) {
189189
var (
190-
maxChunksLimit = d.limits.MaxChunksPerQueryFromIngesters(userID)
191-
totChunksCount = atomic.Int32{}
190+
chunksLimit = d.limits.MaxChunksPerQueryFromIngesters(userID)
191+
chunksCount = atomic.Int32{}
192192
)
193193

194194
// Fetch samples from multiple ingesters
@@ -221,13 +221,13 @@ func (d *Distributor) queryIngesterStream(ctx context.Context, userID string, re
221221
}
222222

223223
// Enforce the max chunks limits.
224-
if maxChunksLimit > 0 {
225-
if totChunks := int(totChunksCount.Add(int32(resp.ChunksCount()))); totChunks > maxChunksLimit {
224+
if chunksLimit > 0 {
225+
if count := int(chunksCount.Add(int32(resp.ChunksCount()))); count > chunksLimit {
226226
// We expect to be always able to convert the label matchers back to Prometheus ones.
227227
// In case we fail (unexpected) the error will not include the matchers, but the core
228228
// logic doesn't break.
229229
matchers, _ := ingester_client.FromLabelMatchers(req.Matchers)
230-
return nil, validation.LimitError(fmt.Sprintf(errMaxChunksPerQueryLimit, util.LabelMatchersToString(matchers), maxChunksLimit))
230+
return nil, validation.LimitError(fmt.Sprintf(errMaxChunksPerQueryLimit, util.LabelMatchersToString(matchers), chunksLimit))
231231
}
232232
}
233233

pkg/util/labels_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ func TestLabelMatchersToString(t *testing.T) {
2626
labels.MustNewMatcher(labels.MatchNotEqual, "who", "boh"),
2727
},
2828
expected: `{foo="bar",who!="boh"}`,
29+
}, {
30+
input: []*labels.Matcher{
31+
labels.MustNewMatcher(labels.MatchEqual, labels.MetricName, "metric"),
32+
labels.MustNewMatcher(labels.MatchNotEqual, "who", "boh"),
33+
},
34+
expected: `{__name__="metric",who!="boh"}`,
2935
},
3036
}
3137

0 commit comments

Comments
 (0)