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)
| 32 | |
| 33 | |
| 34 | def _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 | |
| 50 | def _is_valid_legacy_metric_name(name: str) -> bool: |
no outgoing calls
no test coverage detected