Skip to content

Commit 7691456

Browse files
Put metric before label value in the "label value too long" error mes… (#4018)
* Put metric before label value in the "label value too long" error message (#1582) Signed-off-by: ChinYing-Li <[email protected]> Fix wrong message * Fix the Pull Request number in CHANGELOG.md Signed-off-by: ChinYing-Li <[email protected]> Co-authored-by: Peter Štibraný <[email protected]>
1 parent 8924550 commit 7691456

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* [ENHANCEMENT] Querier / ruler: some optimizations to PromQL query engine. #3934 #3989
2222
* [ENHANCEMENT] Ingester: reduce CPU and memory when an high number of errors are returned by the ingester on the write path with the blocks storage. #3969 #3971 #3973
2323
* [ENHANCEMENT] Distributor: reduce CPU and memory when an high number of errors are returned by the distributor on the write path. #3990
24+
* [ENHANCEMENT] Put metric before label value in the "label value too long" error message. #4018
2425
* [BUGFIX] Ruler-API: fix bug where `/api/v1/rules/<namespace>/<group_name>` endpoint return `400` instead of `404`. #4013
2526
* [BUGFIX] Distributor: reverted changes done to rate limiting in #3825. #3948
2627
* [BUGFIX] Ingester: Fix race condition when opening and closing tsdb concurrently. #3959

pkg/util/validation/errors.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,21 @@ func newLabelNameTooLongError(series []cortexpb.LabelAdapter, labelName string)
3434
}
3535
}
3636

37+
// labelValueTooLongError is a customized ValidationError, in that the cause and the series are
38+
// are formatted in different order in Error.
39+
type labelValueTooLongError struct {
40+
labelValue string
41+
series []cortexpb.LabelAdapter
42+
}
43+
44+
func (e *labelValueTooLongError) Error() string {
45+
return fmt.Sprintf("label value too long for metric: %.200q label value: %.200q", formatLabelSet(e.series), e.labelValue)
46+
}
47+
3748
func newLabelValueTooLongError(series []cortexpb.LabelAdapter, labelValue string) ValidationError {
38-
return &genericValidationError{
39-
message: "label value too long: %.200q metric %.200q",
40-
cause: labelValue,
41-
series: series,
49+
return &labelValueTooLongError{
50+
labelValue: labelValue,
51+
series: series,
4252
}
4353
}
4454

0 commit comments

Comments
 (0)