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

feat: more logs when the input data is wrong somehow #28

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
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
8 changes: 4 additions & 4 deletions vimebu.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,23 @@ func (b *Builder) label(name string, escapeQuote bool, stringValue *string, bool

ln := len(name)
if ln == 0 {
log.Println("label name must not be empty, skipping")
log.Printf("metric: %q, label name must not be empty, skipping", b.underlying)
return b
}
if ln > LabelNameMaxLen {
log.Println("label name contains too many bytes, skipping")
log.Printf("metric: %q, label name: %q, label name contains too many bytes, skipping", b.underlying, name)
return b
}

// String values need to be checked separately as they can be invalid (empty, or contain too many bytes).
if stringValue != nil {
lv := len(*stringValue)
if lv == 0 {
log.Println("label value must not be empty, skipping")
log.Printf("metric: %q, label name: %q, label value must not be empty, skipping", b.underlying, name)
return b
}
if lv > LabelValueLen {
log.Println("label value contains too many bytes, skipping")
log.Printf("metric: %q, label name: %q, label value contains too many bytes, skipping", b.underlying, name)
return b
}
}
Expand Down