Fix CPU is 0. (#2952)

This commit is contained in:
吴晟 Wu Sheng 2019-06-27 07:29:45 +08:00 committed by GitHub
parent 0922548069
commit 62d01382a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -22,6 +22,9 @@ 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.
*
* @author wusheng
*/
public abstract class CPUMetricsAccessor {
@ -46,6 +49,6 @@ public abstract class CPUMetricsAccessor {
long now = System.nanoTime();
CPU.Builder cpuBuilder = CPU.newBuilder();
return cpuBuilder.setUsagePercent(cpuCost * 1.0d / ((now - lastSampleTimeNs) * cpuCoreNum) * 100).build();
return cpuBuilder.setUsagePercent(cpuCost * 1.0d / ((now - lastSampleTimeNs) * cpuCoreNum) * 10000).build();
}
}