You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/04/09 08:02:47 UTC

[incubator-skywalking] branch fix/gc created (now c443182)

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

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


      at c443182  Fix the count of gc is incorrect.

This branch includes the following new commits:

     new c443182  Fix the count of gc is incorrect.

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.


-- 
To stop receiving notification emails like this one, please contact
wusheng@apache.org.

[incubator-skywalking] 01/01: Fix the count of gc is incorrect.

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

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

commit c443182e5a803ff250f4581806ecc07c511b8536
Author: wu-sheng <wu...@foxmail.com>
AuthorDate: Mon Apr 9 16:02:15 2018 +0800

    Fix the count of gc is incorrect.
---
 .../skywalking/apm/agent/core/jvm/gc/GCModule.java       | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/gc/GCModule.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/gc/GCModule.java
index 5582ce2..2789be9 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/gc/GCModule.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/jvm/gc/GCModule.java
@@ -16,7 +16,6 @@
  *
  */
 
-
 package org.apache.skywalking.apm.agent.core.jvm.gc;
 
 import java.lang.management.GarbageCollectorMXBean;
@@ -31,6 +30,9 @@ import org.apache.skywalking.apm.network.proto.GCPhrase;
 public abstract class GCModule implements GCMetricAccessor {
     private List<GarbageCollectorMXBean> beans;
 
+    private long lastGCCount = 0;
+    private long lastCollectionTime = 0;
+
     public GCModule(List<GarbageCollectorMXBean> beans) {
         this.beans = beans;
     }
@@ -49,10 +51,18 @@ public abstract class GCModule implements GCMetricAccessor {
                 continue;
             }
 
+            long collectionCount = bean.getCollectionCount();
+            long gcCount = collectionCount - lastGCCount;
+            lastGCCount = collectionCount;
+
+            long time = bean.getCollectionTime();
+            long gcTime = time - lastCollectionTime;
+            lastCollectionTime = time;
+
             gcList.add(
                 GC.newBuilder().setPhrase(phrase)
-                    .setCount(bean.getCollectionCount())
-                    .setTime(bean.getCollectionTime())
+                    .setCount(gcCount)
+                    .setTime(gcTime)
                     .build()
             );
         }

-- 
To stop receiving notification emails like this one, please contact
wusheng@apache.org.