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 10:53:12 UTC
[incubator-skywalking] branch master updated: Fix the count of gc
is incorrect. (#1054)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 1261e03 Fix the count of gc is incorrect. (#1054)
1261e03 is described below
commit 1261e03c9b7e88b4c5cc94ddc14c9d77c2c11c31
Author: 吴晟 Wu Sheng <wu...@foxmail.com>
AuthorDate: Mon Apr 9 18:53:08 2018 +0800
Fix the count of gc is incorrect. (#1054)
---
.../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.