Skip to content

Commit 5cedc7d

Browse files
authored
Merge pull request #788 from Channyboy/786-v5.0.x
Fix MPmetricbaseMetricsTest so that it is checking gc.time as a gauge…
2 parents 5abc5e8 + 2360484 commit 5cedc7d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

spec/src/main/asciidoc/changelog.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ A full list of changes may be found on the link:https://github.com/eclipse/micro
152152
* (5.0.1) Removed private gauges from TCK (https://github.com/eclipse/microprofile-metrics/pull/770[770])
153153
* (5.0.1) The `@Timed` annotation defaults to SECONDS when it should be NANOSECONDS (https://github.com/eclipse/microprofile-metrics/issues/760[760])
154154
* (5.0.1) Errors in MicroProfile 6.0 javadoc generation (https://github.com/eclipse/microprofile-metrics/issues/764[764])
155+
* (5.0.2) Fix `MPMetricBaseMetricsTest` TCK test where gc.time was being checked as a counter. The `gc.time` metric is a gauge. (https://github.com/eclipse/microprofile-metrics/issues/786[786])
155156

156157
[[release_notes_4_0]]
157158
== Changes in 4.0

tck/optional/src/main/java/org/eclipse/microprofile/metrics/test/optional/MPMetricBaseMetricsTest.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
**********************************************************************
3-
* Copyright (c) 2022 Contributors to the Eclipse Foundation
3+
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation
44
*
55
* See the NOTICES file(s) distributed with this work for additional
66
* information regarding copyright ownership.
@@ -303,28 +303,28 @@ public void testGcTimeMetrics() {
303303
String data = given().header(wantPromMetricsFormat).get("/metrics?scope=base").asString();
304304

305305
Map<String, MiniMeta> baseNames = getExpectedMetadataFromXmlFile(MetricRegistry.BASE_SCOPE);
306-
MiniMeta gcCountMetricMeta = baseNames.get("gc.time");
307-
Set<String> expectedTags = gcCountMetricMeta.tags.keySet();
306+
MiniMeta gcTimeMetricMeta = baseNames.get("gc.time");
307+
Set<String> expectedTags = gcTimeMetricMeta.tags.keySet();
308308

309309
String[] lines = data.split("\n");
310310

311311
boolean found = false;
312312
for (String line : lines) {
313313
// explicitly check for the metric line wth value (i.e. the use of `{`)
314-
if (line.contains("gc_time_seconds_total{")) {
315-
final Pattern gcTimeTotalPattern = Pattern.compile("(gc_time_seconds_total\\{.*?\\}) (\\d+\\.\\d+)");
316-
assertThat("Line format should be gc_time_seconds_total\\{.*?\\} \\d+\\.\\d+",
314+
if (line.contains("gc_time_seconds{")) {
315+
final Pattern gcTimeTotalPattern = Pattern.compile("(gc_time_seconds\\{.*?\\}) (\\d+\\.\\d+)");
316+
assertThat("Line format should be gc_time_seconds\\{.*?\\} \\d+\\.\\d+",
317317
gcTimeTotalPattern.matcher(line).matches());
318318

319319
final String metricID = gcTimeTotalPattern.matcher(line).replaceAll("$1");
320-
final String tags = metricID.replaceAll("^gc_time_seconds_total\\{", "").replaceAll("\\}$", "");
320+
final String tags = metricID.replaceAll("^gc_time_seconds\\{", "").replaceAll("\\}$", "");
321321

322322
for (String expectedTag : expectedTags) {
323323
assertThat("The metric should contain a " + expectedTag + " tag", tags,
324324
containsString(expectedTag + "="));
325325
}
326326
final String value = gcTimeTotalPattern.matcher(line).replaceAll("$2");
327-
Assert.assertTrue("gc.time.seconds.total value should be numeric and not negative",
327+
Assert.assertTrue("gc.time value should be numeric and not negative",
328328
Double.valueOf(value).doubleValue() >= 0);
329329

330330
found = true;

0 commit comments

Comments
 (0)