Update UI, revert #2952 and fix JVM CPU usage again (#2961)

* Update UI.

* Fix CPU time again

* Update UI.
This commit is contained in:
吴晟 Wu Sheng 2019-06-28 10:53:44 +08:00 committed by GitHub
parent c82a230d4c
commit 55d71e0ec3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -22,8 +22,8 @@ package org.apache.skywalking.apm.agent.core.jvm.cpu;
import org.apache.skywalking.apm.network.common.CPU;
/**
* The unit of CPU usage is 1/10000.
* The backend is using `avg` func directly, and query for percentage requires this unit.
* The unit of CPU usage is 1/10000. The backend is using `avg` func directly, and query for percentage requires this
* unit.
*
* @author wusheng
*/
@ -38,7 +38,7 @@ public abstract class CPUMetricsAccessor {
protected void init() {
lastCPUTimeNs = this.getCpuTime();
this.lastSampleTimeNs = System.nanoTime();
lastSampleTimeNs = System.nanoTime();
}
protected abstract long getCpuTime();
@ -48,7 +48,12 @@ public abstract class CPUMetricsAccessor {
long cpuCost = cpuTime - lastCPUTimeNs;
long now = System.nanoTime();
CPU.Builder cpuBuilder = CPU.newBuilder();
return cpuBuilder.setUsagePercent(cpuCost * 1.0d / ((now - lastSampleTimeNs) * cpuCoreNum) * 10000).build();
try {
CPU.Builder cpuBuilder = CPU.newBuilder();
return cpuBuilder.setUsagePercent(cpuCost * 1.0d / ((now - lastSampleTimeNs) * cpuCoreNum) * 100).build();
} finally {
lastCPUTimeNs = cpuTime;
lastSampleTimeNs = now;
}
}
}

@ -1 +1 @@
Subproject commit d48cc15b3a7260ff62a79dab3699db32a6889b3f
Subproject commit 1ace261b8bbef0ac8b799106fb0a8a362571153b