Skip to content

Commit

Permalink
Fix test to follow the new naming behavior of the Prometheus Client
Browse files Browse the repository at this point in the history
The Prometheus Java Client used to let users to use colons (":")
in the metric names. Apparently, this should have not been allowed.

See the docs: https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
"Metric names may contain ASCII letters, digits, underscores,
and colons. It must match the regex [a-zA-Z_:][a-zA-Z0-9_:]*.
Note: The colons are reserved for user defined recording rules.
They should not be used by exporters or direct instrumentation."

So even if metric names can contain colons (":"),
exporters (like the Prometheus Java Client or Micrometer)
should not use it. The Prometheus Java Client replaces colons (":")
to underscores ("_") starting from 1.3.3.

See prometheus/client_java#974
See prometheus/client_java#975
See #5649
  • Loading branch information
jonatan-ivanov committed Nov 7, 2024
1 parent bca46bf commit 269fab3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PrometheusNamingConventionTest {

@Test
void formatName() {
assertThat(convention.name("123abc/{:id}水", Meter.Type.GAUGE)).startsWith("_23abc__:id__");
assertThat(convention.name("123abc/{:id}水", Meter.Type.GAUGE)).startsWith("_23abc___id__");
}

@Test
Expand Down

0 comments on commit 269fab3

Please sign in to comment.