Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put metric before label value in the "label value too long" error mes… #4018

Merged
merged 3 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* [ENHANCEMENT] Query-frontend: reduced memory allocations when serializing query response. #3964
* [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
* [ENHANCEMENT] Distributor: reduce CPU and memory when an high number of errors are returned by the distributor on the write path. #3990
* [ENHANCEMENT] Put metric before label value in the "label value too long" error message. #3982
* [BUGFIX] Distributor: reverted changes done to rate limiting in #3825. #3948
* [BUGFIX] Ingester: Fix race condition when opening and closing tsdb concurrently. #3959
* [BUGFIX] Querier: streamline tracing spans. #3924
Expand Down
18 changes: 14 additions & 4 deletions pkg/util/validation/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ func (e *genericValidationError) Error() string {
return fmt.Sprintf(e.message, e.cause, formatLabelSet(e.series))
}

// labelValueTooLongError is a customized ValidationError, in that the cause and the series are
// are formatted in different order in Error.
type labelValueTooLongError struct {
labelValue string
series []cortexpb.LabelAdapter
}

func (e *labelValueTooLongError) Error() string {
return fmt.Sprintf("label value too long for metric: %.200q label value: %.200q", formatLabelSet(e.series), e.labelValue)
}

func newLabelNameTooLongError(series []cortexpb.LabelAdapter, labelName string) ValidationError {
return &genericValidationError{
message: "label name too long: %.200q metric %.200q",
Expand All @@ -35,10 +46,9 @@ func newLabelNameTooLongError(series []cortexpb.LabelAdapter, labelName string)
}

func newLabelValueTooLongError(series []cortexpb.LabelAdapter, labelValue string) ValidationError {
return &genericValidationError{
message: "label value too long: %.200q metric %.200q",
cause: labelValue,
series: series,
return &labelValueTooLongError{
labelValue: labelValue,
series: series,
}
}

Expand Down