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

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

Merged
merged 2 commits into from
Dec 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions prometheus/desc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package prometheus

import (
"errors"
"fmt"
"sort"
"strings"
Expand Down Expand Up @@ -127,7 +126,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
labelNameSet[labelName] = struct{}{}
}
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also print labelNames? (:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure, I was trying to walk the line between specific enough to give you a place to debug, without giving a flood of unstructured logging. If you think printing the full array is the right move, I'm happy to include that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's useful, usually metric name might be enough, but there might be duplicates of labels too - hard to debug without extra entry.

We can add in next PR though, thanks!

return d
}

Expand Down