|
18 | 18 | */ |
19 | 19 | public class PrometheusNaming { |
20 | 20 |
|
21 | | - /** |
22 | | - * @deprecated Not used anymore. Kept for backward compatibility. The validation is now done |
23 | | - * without regex for better performance. |
24 | | - */ |
25 | | - @Deprecated |
26 | | - @SuppressWarnings("UnusedVariable") |
27 | | - private static final Pattern METRIC_NAME_PATTERN = Pattern.compile("^[a-zA-Z_:][a-zA-Z0-9_:]*$"); |
28 | | - |
29 | | - /** |
30 | | - * Legal characters for label names. |
31 | | - * |
32 | | - * @deprecated Not used anymore. Kept for backward compatibility. The validation is now done |
33 | | - * without regex for better performance. |
34 | | - */ |
35 | | - @Deprecated |
36 | | - @SuppressWarnings("UnusedVariable") |
37 | | - private static final Pattern LEGACY_LABEL_NAME_PATTERN = |
38 | | - Pattern.compile("^[a-zA-Z_][a-zA-Z0-9_]*$"); |
39 | | - |
40 | 21 | /** Legal characters for unit names, including dot. */ |
41 | 22 | private static final Pattern UNIT_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_.:]+$"); |
42 | 23 |
|
@@ -64,7 +45,9 @@ public class PrometheusNaming { |
64 | 45 | * Test if a metric name is valid. Rules: |
65 | 46 | * |
66 | 47 | * <ul> |
67 | | - * <li>The name must be valid UTF-8. |
| 48 | + * <li>The name must match <a |
| 49 | + * href="https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels">Metric |
| 50 | + * names</a>. |
68 | 51 | * <li>The name MUST NOT end with one of the {@link #RESERVED_METRIC_NAME_SUFFIXES}. |
69 | 52 | * </ul> |
70 | 53 | * |
@@ -146,9 +129,7 @@ public static boolean isValidLegacyLabelName(String name) { |
146 | 129 | } |
147 | 130 | // First character must be [a-zA-Z_] |
148 | 131 | char first = name.charAt(0); |
149 | | - if (!((first >= 'a' && first <= 'z') |
150 | | - || (first >= 'A' && first <= 'Z') |
151 | | - || first == '_')) { |
| 132 | + if (!((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z') || first == '_')) { |
152 | 133 | return false; |
153 | 134 | } |
154 | 135 | // Remaining characters must be [a-zA-Z0-9_] |
|
0 commit comments