content: /*
   * Copyright The OpenTelemetry Authors
   * SPDX-License-Identifier: Apache-2.0
   */
  
  package io.opentelemetry.instrumentation.javaagent.runtimemetrics.java17;
  
  import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
  import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
  import org.junit.jupiter.api.Test;
  import org.junit.jupiter.api.extension.RegisterExtension;
  
  class JmxRuntimeMetricsTest {
  
    @RegisterExtension
    static final InstrumentationExtension testing = AgentInstrumentationExtension.create();
  
    @Test
    void runtimeMetricsAreEnabled() {
      // Force a gc to "ensure" gc metrics
      System.gc();
  
      testing.waitAndAssertMetrics(
          "io.opentelemetry.runtime-telemetry-java8",
          metric -> metric.hasName("jvm.class.loaded"),
          metric -> metric.hasName("jvm.class.unloaded"),
          metric -> metric.hasName("jvm.class.count"),
          metric -> metric.hasName("jvm.cpu.time"),
          metric -> metric.hasName("jvm.cpu.count"),
          metric -> metric.hasName("jvm.cpu.recent_utilization"),
          metric -> metric.hasName("jvm.gc.duration"),
          metric -> metric.hasName("jvm.memory.used"),
          metric -> metric.hasName("jvm.memory.committed"),
          metric -> metric.hasName("jvm.memory.limit"),
          metric -> metric.hasName("jvm.memory.used_after_last_gc"),
          metric -> metric.hasName("jvm.thread.count"));
    }
  }
  