Add context to "duplicate label names" to enable debugging (#1177)

* Add context to "duplicate label names" to enable debugging

Signed-off-by: SpencerMalone <malone.spencer@gmail.com>

* Remove unused errors package import.

Signed-off-by: SpencerMalone <malone.spencer@gmail.com>

Signed-off-by: SpencerMalone <malone.spencer@gmail.com>
This commit is contained in:
SpencerMalone 2022-12-13 02:39:55 -08:00 committed by GitHub
parent 07b1397ded
commit 3d765a161a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -14,7 +14,6 @@
package prometheus package prometheus
import ( import (
"errors"
"fmt" "fmt"
"sort" "sort"
"strings" "strings"
@ -127,7 +126,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
labelNameSet[labelName] = struct{}{} labelNameSet[labelName] = struct{}{}
} }
if len(labelNames) != len(labelNameSet) { if len(labelNames) != len(labelNameSet) {
d.err = errors.New("duplicate label names") d.err = fmt.Errorf("duplicate label names in constant and variable labels for metric %q", fqName)
return d return d
} }