Skip to content

Commit fdf8632

Browse files
feat: use stream labels instead of hash in rate limit reasons (#16738)
1 parent 32ef37d commit fdf8632

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎pkg/distributor/distributor.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,11 +1170,17 @@ func (d *Distributor) exceedsLimits(
11701170
if len(resp.RejectedStreams) == 0 {
11711171
return false, nil, nil
11721172
}
1173+
// hashesToLabels memoizes the labels for a stream hash so we can add
1174+
// it to the reason.
1175+
hashesToLabels := make(map[uint64]string)
1176+
for _, s := range streams {
1177+
hashesToLabels[s.HashKeyNoShard] = s.Stream.Labels
1178+
}
11731179
reasons := make([]string, 0, len(resp.RejectedStreams))
11741180
for _, rejection := range resp.RejectedStreams {
11751181
reasons = append(reasons, fmt.Sprintf(
1176-
"stream %x was rejected because %q",
1177-
rejection.StreamHash,
1182+
"stream %s was rejected because %q",
1183+
hashesToLabels[rejection.StreamHash],
11781184
rejection.Reason,
11791185
))
11801186
}

0 commit comments

Comments
 (0)