Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

package io.opentelemetry.contrib.jmxmetrics.target_systems;

import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest;
import java.util.Arrays;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;

import io.opentelemetry.contrib.jmxmetrics.AbstractIntegrationTest;

class JvmTargetSystemIntegrationTest extends AbstractIntegrationTest {

JvmTargetSystemIntegrationTest() {
Expand Down Expand Up @@ -55,6 +57,8 @@ void endToEnd() {
metric -> assertGauge(metric, "jvm.memory.nonheap.init", "current non-heap usage", "By"),
metric -> assertGauge(metric, "jvm.memory.nonheap.max", "current non-heap usage", "By"),
metric -> assertGauge(metric, "jvm.memory.nonheap.used", "current non-heap usage", "By"),
metric -> assertGauge(metric, "jvm.runtime.uptime", "uptime", "ms"),
metric -> assertGauge(metric, "jvm.fd.open", "open file descriptors", "1"),
metric ->
assertTypedGauge(
metric, "jvm.memory.pool.committed", "current memory pool usage", "By", gcLabels),
Expand Down
9 changes: 9 additions & 0 deletions jmx-metrics/src/main/resources/target-systems/jvm.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ otel.instrument(memory, "jvm.memory.heap", "current heap usage",
otel.instrument(memory, "jvm.memory.nonheap", "current non-heap usage",
"By", "NonHeapMemoryUsage", otel.&longValueCallback)

def runtime = otel.mbean("java.lang:type=Runtime")
otel.instrument(runtime, "jvm.runtime.uptime", "uptime",
"ms", "Uptime", otel.&longValueCallback)

def os = otel.mbean("java.lang:type=OperatingSystem")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with how this works, what happens on Windows?

otel.instrument(os, "jvm.fd.open", "open file descriptors",
"1", "OpenFileDescriptorCount", otel.&longValueCallback)


def memoryPool = otel.mbeans("java.lang:type=MemoryPool,*")
otel.instrument(memoryPool, "jvm.memory.pool", "current memory pool usage",
"By", ["name" : { mbean -> mbean.name().getKeyProperty("name") }],
Expand Down
Loading