MCPcopy
hub / github.com/prometheus/client_golang / validateLabelValues

Function validateLabelValues

prometheus/labels.go:166–184  ·  view source on GitHub ↗
(vals []string, expectedNumberOfValues int)

Source from the content-addressed store, hash-verified

164}
165
166func validateLabelValues(vals []string, expectedNumberOfValues int) error {
167 if len(vals) != expectedNumberOfValues {
168 // The call below makes vals escape, copy them to avoid that.
169 vals := append([]string(nil), vals...)
170 return fmt.Errorf(
171 "%w: expected %d label values but got %d in %#v",
172 errInconsistentCardinality, expectedNumberOfValues,
173 len(vals), vals,
174 )
175 }
176
177 for _, val := range vals {
178 if !utf8.ValidString(val) {
179 return fmt.Errorf("label value %q is not valid UTF-8", val)
180 }
181 }
182
183 return nil
184}
185
186func checkLabelName(l string) bool {
187 //nolint:staticcheck // TODO: Don't use deprecated model.NameValidationScheme.

Callers 10

NewConstMetricFunction · 0.85
hashLabelValuesMethod · 0.85
NewConstHistogramFunction · 0.85
NewConstNativeHistogramFunction · 0.85
NewConstSummaryFunction · 0.85
NewDescMethod · 0.85

Calls

no outgoing calls

Tested by 1