You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/06/26 14:28:09 UTC

[skywalking] branch metrics-fix created (now 240c673)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a change to branch metrics-fix
in repository https://gitbox.apache.org/repos/asf/skywalking.git.


      at 240c673  Fix CPU is 0.

This branch includes the following new commits:

     new 240c673  Fix CPU is 0.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking] 01/01: Fix CPU is 0.

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch metrics-fix
in repository https://gitbox.apache.org/repos/asf/skywalking.git

commit 240c6735f5167a3772e9e8e5179a3c82e8a5bd3b
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Jun 26 22:27:31 2019 +0800

    Fix CPU is 0.
---
 .../apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricsAccessor.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricsAccessor.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricsAccessor.java
index 174d209..140a3d1 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricsAccessor.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/cpu/CPUMetricsAccessor.java
@@ -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();
     }
 }