Skip to content

Commit 490aa6d

Browse files
committed
format
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
1 parent 5266417 commit 490aa6d

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/snapshots/PrometheusNaming.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,6 @@
1818
*/
1919
public class PrometheusNaming {
2020

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-
4021
/** Legal characters for unit names, including dot. */
4122
private static final Pattern UNIT_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_.:]+$");
4223

@@ -64,7 +45,9 @@ public class PrometheusNaming {
6445
* Test if a metric name is valid. Rules:
6546
*
6647
* <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>.
6851
* <li>The name MUST NOT end with one of the {@link #RESERVED_METRIC_NAME_SUFFIXES}.
6952
* </ul>
7053
*
@@ -146,9 +129,7 @@ public static boolean isValidLegacyLabelName(String name) {
146129
}
147130
// First character must be [a-zA-Z_]
148131
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 == '_')) {
152133
return false;
153134
}
154135
// Remaining characters must be [a-zA-Z0-9_]

0 commit comments

Comments
 (0)