JmxRuntimeMetricsTest.groovy 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright The OpenTelemetry Authors
  3. * SPDX-License-Identifier: Apache-2.0
  4. */
  5. import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
  6. import spock.util.concurrent.PollingConditions
  7. class JmxRuntimeMetricsTest extends AgentInstrumentationSpecification {
  8. def "test runtime metrics is enabled"() {
  9. when:
  10. def conditions = new PollingConditions(timeout: 10, initialDelay: 1.5, factor: 1.25)
  11. // Force a gc to ensure gc metrics
  12. System.gc()
  13. then:
  14. conditions.eventually {
  15. assert getMetrics().any { it.name == "process.runtime.jvm.classes.loaded" }
  16. assert getMetrics().any { it.name == "process.runtime.jvm.classes.unloaded" }
  17. assert getMetrics().any { it.name == "process.runtime.jvm.classes.current_loaded" }
  18. assert getMetrics().any { it.name == "process.runtime.jvm.system.cpu.load_1m" }
  19. assert getMetrics().any { it.name == "process.runtime.jvm.system.cpu.utilization" }
  20. assert getMetrics().any { it.name == "process.runtime.jvm.cpu.utilization" }
  21. assert getMetrics().any { it.name == "process.runtime.jvm.gc.duration" }
  22. assert getMetrics().any { it.name == "process.runtime.jvm.memory.init" }
  23. assert getMetrics().any { it.name == "process.runtime.jvm.memory.usage" }
  24. assert getMetrics().any { it.name == "process.runtime.jvm.memory.committed" }
  25. assert getMetrics().any { it.name == "process.runtime.jvm.memory.limit" }
  26. assert getMetrics().any { it.name == "process.runtime.jvm.memory.usage_after_last_gc" }
  27. assert getMetrics().any { it.name == "process.runtime.jvm.threads.count" }
  28. assert getMetrics().any { it.name == "process.runtime.jvm.buffer.limit" }
  29. assert getMetrics().any { it.name == "process.runtime.jvm.buffer.count" }
  30. assert getMetrics().any { it.name == "process.runtime.jvm.buffer.usage" }
  31. }
  32. }
  33. }