Browse Source

Filter the NaN of system_cpu_usage/process_cpu_usage (#16289)

dev
Wenjun Ruan 4 months ago committed by GitHub
parent
commit
255ec35c3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      dolphinscheduler-meter/src/main/java/org/apache/dolphinscheduler/meter/metrics/DefaultMetricsProvider.java

13
dolphinscheduler-meter/src/main/java/org/apache/dolphinscheduler/meter/metrics/DefaultMetricsProvider.java

@ -33,6 +33,9 @@ public class DefaultMetricsProvider implements MetricsProvider {
private long lastRefreshTime = 0;
private double lastSystemCpuUsage = 0.0d;
private double lastProcessCpuUsage = 0.0d;
private static final long SYSTEM_METRICS_REFRESH_INTERVAL = 1_000L;
@Override
@ -42,7 +45,17 @@ public class DefaultMetricsProvider implements MetricsProvider {
}
double systemCpuUsage = meterRegistry.get("system.cpu.usage").gauge().value();
if (Double.compare(systemCpuUsage, Double.NaN) == 0) {
systemCpuUsage = lastSystemCpuUsage;
} else {
lastSystemCpuUsage = systemCpuUsage;
}
double processCpuUsage = meterRegistry.get("process.cpu.usage").gauge().value();
if (Double.compare(processCpuUsage, Double.NaN) == 0) {
processCpuUsage = lastProcessCpuUsage;
} else {
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();

Loading…
Cancel
Save