Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek committed Dec 8, 2022
1 parent 8d1e877 commit a987330
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import java.util.ArrayList;
import java.util.List;
import org.assertj.core.api.AbstractIterableAssert;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -32,12 +34,22 @@ class OtelJvmMetricsTest {

@Test
void shouldRegisterOtelJvmMeters() {
// exercise the GC for a bit
{
List<Long[]> garbage = new ArrayList<>();
for (int i = 0; i < 10_000; ++i) {
garbage.add(new Long[i]);
}
garbage.clear();
}
System.gc();

// GC metrics
assertOtelMetricPresent("runtime.jvm.gc.memory.allocated");
// GC pressure metrics
assertOtelMetricPresent("runtime.jvm.gc.overhead");
// thread metrics
assertOtelMetricPresent("runtime.jvm.threads.peak");
assertOtelMetricPresent("runtime.jvm.threads.states");
// allocated memory metrics
assertOtelMetricPresent(AllocatedMemoryMetrics.METRIC_NAME);
// Our custom GC metrics
Expand Down

0 comments on commit a987330

Please sign in to comment.