Skip to content

Commit 0304bd8

Browse files
committed
add test for jvm.cpu.time
1 parent bb20251 commit 0304bd8

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

instrumentation/jmx-metrics/library/src/main/resources/jmx/rules/jvm.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ rules:
6363

6464
- bean: java.lang:type=OperatingSystem
6565
prefix: jvm.
66+
# TODO: drop negative values once https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/13589 is merged
67+
# dropNegativeValues: true
6668
mapping:
6769
# jvm.cpu.count
6870
AvailableProcessors:
@@ -71,35 +73,30 @@ rules:
7173
unit: "{cpu}"
7274
desc: Number of processors available to the Java virtual machine.
7375
# jvm.cpu.time
74-
# TODO requires time unit conversion to seconds be semconv compliant, so disabled for now
75-
# https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/13369
76-
# ProcessCpuTime:
77-
# metric: jvm.cpu.time
78-
# type: counter
79-
# unit: ns
80-
# desc: CPU time used by the process as reported by the JVM.
81-
# # TODO: should we filter zero values ?
76+
ProcessCpuTime:
77+
metric: jvm.cpu.time
78+
type: counter
79+
sourceUnit: ns
80+
unit: s
81+
desc: CPU time used by the process as reported by the JVM.
8282
# jvm.cpu.recent_utilization
8383
ProcessCpuLoad:
8484
metric: cpu.recent_utilization
8585
type: gauge
8686
unit: '1'
8787
desc: Recent CPU utilization for the process as reported by the JVM.
88-
# TODO: should we filter zero values ?
8988
# jvm.system.cpu.load_1m (experimental)
9089
SystemLoadAverage:
9190
metric: system.cpu.load_1m
9291
type: gauge
9392
unit: "{run_queue_item}"
9493
desc: Average CPU load of the whole system for the last minute as reported by the JVM.
95-
# TODO: should we filter zero values ?
9694
# jvm.system.cpu.utilization (experimental)
9795
SystemCpuLoad:
9896
metric: system.cpu.utilization
9997
type: gauge
10098
unit: '1'
10199
desc: Recent CPU utilization for the whole system as reported by the JVM.
102-
# TODO: should we filter zero values ?
103100

104101
- bean: java.nio:name=*,type=BufferPool
105102
prefix: jvm.buffer.

instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/rules/JvmTargetSystemTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ void testJvmMetrics(String image) {
145145
.hasUnit("{cpu}")
146146
.isUpDownCounter()
147147
.hasDataPointsWithoutAttributes())
148+
.add("jvm.cpu.time", metric -> metric
149+
.hasDescription("CPU time used by the process as reported by the JVM.")
150+
.hasUnit("s")
151+
.isCounter()
152+
.hasDataPointsWithoutAttributes())
148153
.add(
149154
"jvm.cpu.recent_utilization",
150155
metric ->

0 commit comments

Comments
 (0)