Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Unreleased

* [CHANGE] prometheus: Name validation now always uses the UTF-8 scheme instead of the deprecated `model.NameValidationScheme` global. Default behavior is unchanged; code that set `NameValidationScheme = LegacyValidation` no longer gets legacy enforcement at metric, label, and push-grouping construction. #2051
Comment thread
bwplotka marked this conversation as resolved.
* [FEATURE] HTTP handlers created by `promhttp` package now support metrics filtering by providing one or more `name[]` query parameters. The default behavior when none are provided remains the same, returning all metrics. #1925
* [BUGFIX] promhttp: `InstrumentHandlerDuration` and `InstrumentHandlerCounter` no longer panic when given an observer/counter that does not implement `ExemplarObserver`/`ExemplarAdder` (e.g. a `SummaryVec`). The exemplar is dropped and the value is recorded via the plain `Observe`/`Add` path, matching the safe-cast already used by `Timer.ObserveDurationWithExemplar`. #2005

Expand Down
3 changes: 1 addition & 2 deletions prometheus/desc.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ func (v2) NewDesc(fqName, help string, variableLabels ConstrainableLabels, const
for _, opt := range opts {
opt(d)
}
//nolint:staticcheck // TODO: Don't use deprecated model.NameValidationScheme.
if !model.NameValidationScheme.IsValidMetricName(fqName) {
if !model.UTF8Validation.IsValidMetricName(fqName) {
d.err = fmt.Errorf("%q is not a valid metric name", fqName)
return d
}
Expand Down
3 changes: 1 addition & 2 deletions prometheus/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,5 @@ func validateLabelValues(vals []string, expectedNumberOfValues int) error {
}

func checkLabelName(l string) bool {
//nolint:staticcheck // TODO: Don't use deprecated model.NameValidationScheme.
return model.NameValidationScheme.IsValidLabelName(l) && !strings.HasPrefix(l, reservedLabelPrefix)
return model.UTF8Validation.IsValidLabelName(l) && !strings.HasPrefix(l, reservedLabelPrefix)
}
3 changes: 1 addition & 2 deletions prometheus/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ func (p *Pusher) Error() error {
// For convenience, this method returns a pointer to the Pusher itself.
func (p *Pusher) Grouping(name, value string) *Pusher {
if p.error == nil {
//nolint:staticcheck // TODO: Don't use deprecated model.NameValidationScheme.
if !model.NameValidationScheme.IsValidLabelName(name) {
if !model.UTF8Validation.IsValidLabelName(name) {
p.error = fmt.Errorf("grouping label has invalid name: %s", name)
return p
}
Expand Down
Loading