scrape: Update error message for label limits

Signed-off-by: Jayapriya Pai <janantha@redhat.com>
This commit is contained in:
Jayapriya Pai 2022-03-09 18:57:50 +05:30 committed by Julien Pivotto
parent 0b41fd6e71
commit 580e852f10
1 changed files with 3 additions and 3 deletions

View File

@ -619,7 +619,7 @@ func verifyLabelLimits(lset labels.Labels, limits *labelLimits) error {
if limits.labelLimit > 0 { if limits.labelLimit > 0 {
nbLabels := len(lset) nbLabels := len(lset)
if nbLabels > int(limits.labelLimit) { if nbLabels > int(limits.labelLimit) {
return fmt.Errorf("label_limit exceeded (metric: %.50s, number of label: %d, limit: %d)", met, nbLabels, limits.labelLimit) return fmt.Errorf("label_limit exceeded (metric: %.50s, number of labels: %d, limit: %d)", met, nbLabels, limits.labelLimit)
} }
} }
@ -631,14 +631,14 @@ func verifyLabelLimits(lset labels.Labels, limits *labelLimits) error {
if limits.labelNameLengthLimit > 0 { if limits.labelNameLengthLimit > 0 {
nameLength := len(l.Name) nameLength := len(l.Name)
if nameLength > int(limits.labelNameLengthLimit) { if nameLength > int(limits.labelNameLengthLimit) {
return fmt.Errorf("label_name_length_limit exceeded (metric: %.50s, label: %.50v, name length: %d, limit: %d)", met, l, nameLength, limits.labelNameLengthLimit) return fmt.Errorf("label_name_length_limit exceeded (metric: %.50s, label name: %.50s, length: %d, limit: %d)", met, l.Name, nameLength, limits.labelNameLengthLimit)
} }
} }
if limits.labelValueLengthLimit > 0 { if limits.labelValueLengthLimit > 0 {
valueLength := len(l.Value) valueLength := len(l.Value)
if valueLength > int(limits.labelValueLengthLimit) { if valueLength > int(limits.labelValueLengthLimit) {
return fmt.Errorf("label_value_length_limit exceeded (metric: %.50s, label: %.50v, value length: %d, limit: %d)", met, l, valueLength, limits.labelValueLengthLimit) return fmt.Errorf("label_value_length_limit exceeded (metric: %.50s, label name: %.50s, value: %.50q, length: %d, limit: %d)", met, l.Name, l.Value, valueLength, limits.labelValueLengthLimit)
} }
} }
} }