Skip to content

Commit 1635c33

Browse files
committed
Address a review comment
Signed-off-by: 🌲 Harry 🌊 John 🏔 <[email protected]>
1 parent 3a087de commit 1635c33

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

pkg/distributor/distributor.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,11 +1027,11 @@ func (d *Distributor) MetricsForLabelMatchers(ctx context.Context, from, through
10271027
if err != nil {
10281028
return nil, err
10291029
}
1030+
if err := queryLimiter.AddDataBytes(resp.Size()); err != nil {
1031+
return nil, err
1032+
}
10301033
ms := ingester_client.FromMetricsForLabelMatchersResponse(resp)
10311034
for _, m := range ms {
1032-
if err := queryLimiter.AddDataBytes(resp.Size()); err != nil {
1033-
return nil, err
1034-
}
10351035
if err := queryLimiter.AddSeries(cortexpb.FromMetricsToLabelAdapters(m)); err != nil {
10361036
return nil, err
10371037
}
@@ -1058,6 +1058,9 @@ func (d *Distributor) MetricsForLabelMatchersStream(ctx context.Context, from, t
10581058
defer stream.CloseSend() //nolint:errcheck
10591059
for {
10601060
resp, err := stream.Recv()
1061+
if err := queryLimiter.AddDataBytes(resp.Size()); err != nil {
1062+
return nil, err
1063+
}
10611064

10621065
if err == io.EOF {
10631066
break
@@ -1068,9 +1071,6 @@ func (d *Distributor) MetricsForLabelMatchersStream(ctx context.Context, from, t
10681071
for _, metric := range resp.Metric {
10691072
m := cortexpb.FromLabelAdaptersToMetricWithCopy(metric.Labels)
10701073

1071-
if err := queryLimiter.AddDataBytes(resp.Size()); err != nil {
1072-
return nil, err
1073-
}
10741074
if err := queryLimiter.AddSeries(metric.Labels); err != nil {
10751075
return nil, err
10761076
}

pkg/querier/blocks_store_queryable.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,7 @@ func (q *blocksStoreQuerier) fetchSeriesFromStores(
691691

692692
numSeries := len(mySeries)
693693
chunkBytes := countChunkBytes(mySeries...)
694-
labelBytes := countDataBytes(mySeries...)
695-
dataBytes := labelBytes + chunkBytes
694+
dataBytes := countDataBytes(mySeries...)
696695

697696
reqStats.AddFetchedSeries(uint64(numSeries))
698697
reqStats.AddFetchedChunkBytes(uint64(chunkBytes))
@@ -1008,7 +1007,7 @@ func countChunkBytes(series ...*storepb.Series) (count int) {
10081007
return count
10091008
}
10101009

1011-
// countChunkBytes returns the size of the chunks making up the provided series in bytes
1010+
// countDataBytes returns the combined size of the all the series
10121011
func countDataBytes(series ...*storepb.Series) (count int) {
10131012
for _, s := range series {
10141013
count += s.Size()

pkg/util/limiter/query_limiter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (ql *QueryLimiter) AddChunkBytes(chunkSizeInBytes int) error {
102102
return nil
103103
}
104104

105-
// AddDataBytes adds the input label size in bytes and returns an error if the limit is reached.
105+
// AddDataBytes adds the queried data bytes and returns an error if the limit is reached.
106106
func (ql *QueryLimiter) AddDataBytes(dataSizeInBytes int) error {
107107
if ql.maxDataBytesPerQuery == 0 {
108108
return nil

0 commit comments

Comments
 (0)