dill21yu commented on code in PR #17174:
URL:
https://github.com/apache/dolphinscheduler/pull/17174#discussion_r2086035217
##########
dolphinscheduler-meter/src/main/java/org/apache/dolphinscheduler/meter/metrics/DefaultMetricsProvider.java:
##########
@@ -59,8 +60,19 @@ public SystemMetrics getSystemMetrics() {
lastProcessCpuUsage = processCpuUsage;
}
- double jvmMemoryUsed =
meterRegistry.get("jvm.memory.used").meter().measure().iterator().next().getValue();
- double jvmMemoryMax =
meterRegistry.get("jvm.memory.max").meter().measure().iterator().next().getValue();
+ // Calculate JVM memory usage and maximum values
+ double jvmHeapUsed = calculateTotalMemory(meterRegistry, "heap",
"jvm.memory.used");
+ double jvmNonHeapUsed = calculateTotalMemory(meterRegistry, "nonheap",
"jvm.memory.used");
+
+ double jvmHeapMax = calculateTotalMemory(meterRegistry, "heap",
"jvm.memory.max");
+ double jvmNonHeapMax = calculateTotalMemory(meterRegistry, "nonheap",
"jvm.memory.max");
+
+ // Calculate totals
+ double jvmMemoryUsed = jvmHeapUsed + jvmNonHeapUsed;
+ double jvmMemoryMax = jvmHeapMax + jvmNonHeapMax;
+
+ // Ensure jvmMemoryMax is not zero
+ double jvmMemoryUsedPercentage = (jvmMemoryMax > 0) ? (jvmMemoryUsed /
jvmMemoryMax) : 0.0;
Review Comment:

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]