Skip to content

Commit

Permalink
Make gc metric test more lenient
Browse files Browse the repository at this point in the history
Shenandoah in JDK 21 offers finer grain metrics per action. The test was written too strictly and did not allow for this. Hopefully other GCs will follow suit and provide better tagging data for metrics.

Fixes gh-4257
  • Loading branch information
shakuzen committed Oct 18, 2023
1 parent 3ef954f commit 6d23549
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,12 @@ void gcMetricsAvailableAfterGc() {
.untilAsserted(() -> assertThat(registry.find("jvm.gc.live.data.size").gauge().value()).isPositive());
assertThat(registry.find("jvm.gc.memory.allocated").counter().count()).isPositive();
assertThat(registry.find("jvm.gc.max.data.size").gauge().value()).isPositive();
Optional<Timer> optionalGcTimer = registry.find("jvm.gc.pause")
.timers()
.stream()
.filter(timer -> "System.gc()".equals(timer.getId().getTag("cause")))
.findFirst();
assertThat(optionalGcTimer).isPresent();
Timer gcTimer = optionalGcTimer.get();
Timer gcTimer = registry.find("jvm.gc.pause").tag("cause", "System.gc()").timer();
assertThat(gcTimer).isNotNull();
assertThat(gcTimer.count()).isPositive();
assertThat(gcTimer.getId().getTag("gc")).isNotBlank();
assertThat(gcTimer.getId().getTag("key")).hasToString("value");
assertThat(gcTimer.getId().getTag("action")).isIn("end of major GC", "end of GC pause");
assertThat(gcTimer.getId().getTag("key")).isEqualTo("value");
assertThat(gcTimer.getId().getTag("action")).isNotBlank();

if (!binder.isGenerationalGc) {
return;
Expand Down

0 comments on commit 6d23549

Please sign in to comment.