MCPcopy Index your code
hub / github.com/prometheus/client_python / _validate_labelname

Function _validate_labelname

prometheus_client/validation.py:75–91  ·  view source on GitHub ↗

Raises ValueError if the provided name is not a valid label name. This check uses the global legacy validation setting to determine the validation scheme.

(l)

Source from the content-addressed store, hash-verified

73
74
75def _validate_labelname(l):
76 """Raises ValueError if the provided name is not a valid label name.
77
78 This check uses the global legacy validation setting to determine the validation scheme.
79 """
80 if get_legacy_validation():
81 if not METRIC_LABEL_NAME_RE.match(l):
82 raise ValueError('Invalid label metric name: ' + l)
83 if RESERVED_METRIC_LABEL_NAME_RE.match(l):
84 raise ValueError('Reserved label metric name: ' + l)
85 else:
86 try:
87 l.encode('utf-8')
88 except UnicodeDecodeError:
89 raise ValueError('Invalid label metric name: ' + l)
90 if RESERVED_METRIC_LABEL_NAME_RE.match(l):
91 raise ValueError('Reserved label metric name: ' + l)
92
93
94def _is_valid_legacy_labelname(l: str) -> bool:

Callers 3

parse_labelsFunction · 0.85
_validate_labelnamesFunction · 0.85
_validate_exemplarFunction · 0.85

Calls 1

get_legacy_validationFunction · 0.85

Tested by

no test coverage detected