Skip to content

Commit fbd94e6

Browse files
committed
coverage
Signed-off-by: Gregor Zeitlinger <[email protected]>
1 parent 7244c59 commit fbd94e6

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

prometheus-metrics-exposition-textformats/src/test/java/io/prometheus/metrics/expositionformats/ExpositionFormatsTest.java

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ public void testCounterMinimal() throws IOException {
266266
@Test
267267
public void testCounterWithDots() throws IOException {
268268
String openMetricsText =
269-
"# TYPE my_request_count counter\n"
270-
+ "my_request_count_total{http_path=\"/hello\"} 3.0 # "
271-
+ exemplarWithDotsString
272-
+ "\n"
273-
+ "# EOF\n";
269+
"""
270+
# TYPE U__my_2e_request_2e_count counter
271+
U__my_2e_request_2e_count_total{U__http_2e_path="/hello"} 3.0 # {U__some_2e_exemplar_2e_key="some value"} 3.0 1690298864.383
272+
# EOF
273+
""";
274274
String prometheusText =
275275
"""
276276
# TYPE my_request_count_total counter
@@ -417,10 +417,10 @@ public void testGaugeMinimal() throws IOException {
417417
public void testGaugeWithDots() throws IOException {
418418
String openMetricsText =
419419
"""
420-
# TYPE my_temperature_celsius gauge
421-
# UNIT my_temperature_celsius celsius
422-
# HELP my_temperature_celsius Temperature
423-
my_temperature_celsius{location_id="data-center-1"} 23.0
420+
# TYPE U__my_2e_temperature_2e_celsius gauge
421+
# UNIT U__my_2e_temperature_2e_celsius celsius
422+
# HELP U__my_2e_temperature_2e_celsius Temperature
423+
U__my_2e_temperature_2e_celsius{U__location_2e_id="data-center-1"} 23.0
424424
# EOF
425425
""";
426426
String openMetricsTextWithExemplarsOnAllTimeSeries =
@@ -1016,11 +1016,11 @@ public void testSummaryEmptyAndNonEmpty() throws IOException {
10161016
public void testSummaryWithDots() throws IOException {
10171017
String openMetricsText =
10181018
"""
1019-
# TYPE my_request_duration_seconds summary
1020-
# UNIT my_request_duration_seconds seconds
1021-
# HELP my_request_duration_seconds Request duration in seconds
1022-
my_request_duration_seconds_count{http_path="/hello"} 1
1023-
my_request_duration_seconds_sum{http_path="/hello"} 0.03
1019+
# TYPE U__my_2e_request_2e_duration_2e_seconds summary
1020+
# UNIT U__my_2e_request_2e_duration_2e_seconds seconds
1021+
# HELP U__my_2e_request_2e_duration_2e_seconds Request duration in seconds
1022+
U__my_2e_request_2e_duration_2e_seconds_count{U__http_2e_path="/hello"} 1
1023+
U__my_2e_request_2e_duration_2e_seconds_sum{U__http_2e_path="/hello"} 0.03
10241024
# EOF
10251025
""";
10261026
String openMetricsTextWithExemplarsOnAllTimeSeries =
@@ -1878,15 +1878,15 @@ public void testClassicGaugeHistogramCountAndSum() throws IOException {
18781878
@Test
18791879
public void testClassicHistogramWithDots() throws IOException {
18801880
String openMetricsText =
1881-
"# TYPE my_request_duration_seconds histogram\n"
1882-
+ "# UNIT my_request_duration_seconds seconds\n"
1883-
+ "# HELP my_request_duration_seconds Request duration in seconds\n"
1884-
+ "my_request_duration_seconds_bucket{http_path=\"/hello\",le=\"+Inf\"} 130 # "
1885-
+ exemplarWithDotsString
1886-
+ "\n"
1887-
+ "my_request_duration_seconds_count{http_path=\"/hello\"} 130\n"
1888-
+ "my_request_duration_seconds_sum{http_path=\"/hello\"} 0.01\n"
1889-
+ "# EOF\n";
1881+
"""
1882+
# TYPE U__my_2e_request_2e_duration_2e_seconds histogram
1883+
# UNIT U__my_2e_request_2e_duration_2e_seconds seconds
1884+
# HELP U__my_2e_request_2e_duration_2e_seconds Request duration in seconds
1885+
U__my_2e_request_2e_duration_2e_seconds_bucket{U__http_2e_path="/hello",le="+Inf"} 130 # {U__some_2e_exemplar_2e_key="some value"} 3.0 1690298864.383
1886+
U__my_2e_request_2e_duration_2e_seconds_count{U__http_2e_path="/hello"} 130
1887+
U__my_2e_request_2e_duration_2e_seconds_sum{U__http_2e_path="/hello"} 0.01
1888+
# EOF
1889+
""";
18901890
String openMetricsTextWithExemplarsOnAllTimeSeries =
18911891
"# TYPE my_request_duration_seconds histogram\n"
18921892
+ "# UNIT my_request_duration_seconds seconds\n"
@@ -2299,15 +2299,15 @@ public void testNativeHistogramMinimal() throws IOException {
22992299
@Test
23002300
public void testNativeHistogramWithDots() throws IOException {
23012301
String openMetricsText =
2302-
"# TYPE my_request_duration_seconds histogram\n"
2303-
+ "# UNIT my_request_duration_seconds seconds\n"
2304-
+ "# HELP my_request_duration_seconds Request duration in seconds\n"
2305-
+ "my_request_duration_seconds_bucket{http_path=\"/hello\",le=\"+Inf\"} 4 # "
2306-
+ exemplarWithDotsString
2307-
+ "\n"
2308-
+ "my_request_duration_seconds_count{http_path=\"/hello\"} 4\n"
2309-
+ "my_request_duration_seconds_sum{http_path=\"/hello\"} 3.2\n"
2310-
+ "# EOF\n";
2302+
"""
2303+
# TYPE U__my_2e_request_2e_duration_2e_seconds histogram
2304+
# UNIT U__my_2e_request_2e_duration_2e_seconds seconds
2305+
# HELP U__my_2e_request_2e_duration_2e_seconds Request duration in seconds
2306+
U__my_2e_request_2e_duration_2e_seconds_bucket{U__http_2e_path="/hello",le="+Inf"} 4 # {U__some_2e_exemplar_2e_key="some value"} 3.0 1690298864.383
2307+
U__my_2e_request_2e_duration_2e_seconds_count{U__http_2e_path="/hello"} 4
2308+
U__my_2e_request_2e_duration_2e_seconds_sum{U__http_2e_path="/hello"} 3.2
2309+
# EOF
2310+
""";
23112311
String openMetricsTextWithExemplarsOnAllTimeSeries =
23122312
"# TYPE my_request_duration_seconds histogram\n"
23132313
+ "# UNIT my_request_duration_seconds seconds\n"
@@ -2409,9 +2409,9 @@ public void testInfo() throws IOException {
24092409
public void testInfoWithDots() throws IOException {
24102410
String openMetricsText =
24112411
"""
2412-
# TYPE jvm_status info
2413-
# HELP jvm_status JVM status info
2414-
jvm_status_info{jvm_version="1.2.3"} 1
2412+
# TYPE U__jvm_2e_status info
2413+
# HELP U__jvm_2e_status JVM status info
2414+
U__jvm_2e_status_info{U__jvm_2e_version="1.2.3"} 1
24152415
# EOF
24162416
""";
24172417
String prometheusText =
@@ -2536,10 +2536,10 @@ public void testStateSetMinimal() throws IOException {
25362536
public void testStateSetWithDots() throws IOException {
25372537
String openMetricsText =
25382538
"""
2539-
# TYPE my_application_state stateset
2540-
# HELP my_application_state My application state
2541-
my_application_state{data_center="us east",my_application_state="feature.enabled"} 1
2542-
my_application_state{data_center="us east",my_application_state="is.alpha.version"} 0
2539+
# TYPE U__my_2e_application_2e_state stateset
2540+
# HELP U__my_2e_application_2e_state My application state
2541+
U__my_2e_application_2e_state{U__data_2e_center="us east",U__my_2e_application_2e_state="feature.enabled"} 1
2542+
U__my_2e_application_2e_state{U__data_2e_center="us east",U__my_2e_application_2e_state="is.alpha.version"} 0
25432543
# EOF
25442544
""";
25452545
String prometheusText =
@@ -2673,10 +2673,10 @@ public void testUnknownMinimal() throws IOException {
26732673
public void testUnknownWithDots() throws IOException {
26742674
String openMetrics =
26752675
"""
2676-
# TYPE some_unknown_metric_bytes unknown
2677-
# UNIT some_unknown_metric_bytes bytes
2678-
# HELP some_unknown_metric_bytes help message
2679-
some_unknown_metric_bytes{test_env="7"} 0.7
2676+
# TYPE U__some_2e_unknown_2e_metric__bytes unknown
2677+
# UNIT U__some_2e_unknown_2e_metric__bytes bytes
2678+
# HELP U__some_2e_unknown_2e_metric__bytes help message
2679+
U__some_2e_unknown_2e_metric__bytes{U__test_2e_env="7"} 0.7
26802680
# EOF
26812681
""";
26822682
String openMetricsWithExemplarsOnAllTimeSeries =
@@ -2823,7 +2823,7 @@ private void assertOpenMetricsText(String expected, MetricSnapshot snapshot) thr
28232823
ByteArrayOutputStream out = new ByteArrayOutputStream();
28242824
OpenMetricsTextFormatWriter writer =
28252825
OpenMetricsTextFormatWriter.builder().setCreatedTimestampsEnabled(true).build();
2826-
writer.write(out, MetricSnapshots.of(snapshot), EscapingScheme.UNDERSCORE_ESCAPING);
2826+
writer.write(out, MetricSnapshots.of(snapshot), EscapingScheme.VALUE_ENCODING_ESCAPING);
28272827
assertThat(out).hasToString(expected);
28282828
}
28292829

0 commit comments

Comments
 (0)