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

Function _validate_metric_name

prometheus_client/validation.py:34–47  ·  view source on GitHub ↗

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

(name: str)

Source from the content-addressed store, hash-verified

32
33
34def _validate_metric_name(name: str) -> None:
35 """Raises ValueError if the provided name is not a valid metric name.
36
37 This check uses the global legacy validation setting to determine the validation scheme.
38 """
39 if not name:
40 raise ValueError("metric name cannot be empty")
41 if _legacy_validation:
42 if not METRIC_NAME_RE.match(name):
43 raise ValueError("invalid metric name " + name)
44 try:
45 name.encode('utf-8')
46 except UnicodeDecodeError:
47 raise ValueError("invalid metric name " + name)
48
49
50def _is_valid_legacy_metric_name(name: str) -> bool:

Callers 4

parse_labelsFunction · 0.85
__init__Method · 0.85
__init__Method · 0.85
build_metricFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected