Support collecting metrics of ZGC (#89)
Co-authored-by: litexu <litexu@tencent.com>
This commit is contained in:
parent
7b160b5fec
commit
634cf279a9
|
|
@ -20,6 +20,7 @@ Release Notes.
|
|||
* Fix the bug that httpasyncclient-4.x-plugin puts the dirty tracing context in the connection context
|
||||
* Compatible with the versions after dubbo-2.7.14
|
||||
* Follow protocol grammar fix `GCPhrase -> GCPhase`.
|
||||
* Support ZGC GC time and count metric collect. (Require 9.0.0 OAP)
|
||||
|
||||
#### Documentation
|
||||
|
||||
|
|
|
|||
|
|
@ -35,4 +35,9 @@ public class CMSGCModule extends GCModule {
|
|||
protected String getNewGCName() {
|
||||
return "ParNew";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNormalGCName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,9 @@ public class G1GCModule extends GCModule {
|
|||
protected String getNewGCName() {
|
||||
return "G1 Young Generation";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNormalGCName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ public abstract class GCModule implements GCMetricAccessor {
|
|||
private long lastYGCCount = 0;
|
||||
private long lastOGCCollectionTime = 0;
|
||||
private long lastYGCCollectionTime = 0;
|
||||
private long lastNormalGCCount = 0;
|
||||
private long lastNormalGCTime = 0;
|
||||
|
||||
public GCModule(List<GarbageCollectorMXBean> beans) {
|
||||
this.beans = beans;
|
||||
|
|
@ -62,6 +64,15 @@ public abstract class GCModule implements GCMetricAccessor {
|
|||
long time = bean.getCollectionTime();
|
||||
gcTime = time - lastOGCCollectionTime;
|
||||
lastOGCCollectionTime = time;
|
||||
} else if (name.equals(getNormalGCName())) {
|
||||
phase = GCPhase.NORMAL;
|
||||
long collectionCount = bean.getCollectionCount();
|
||||
gcCount = collectionCount - lastNormalGCCount;
|
||||
lastNormalGCCount = collectionCount;
|
||||
|
||||
long time = bean.getCollectionTime();
|
||||
gcTime = time - lastNormalGCTime;
|
||||
lastNormalGCTime = time;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -75,4 +86,6 @@ public abstract class GCModule implements GCMetricAccessor {
|
|||
protected abstract String getOldGCName();
|
||||
|
||||
protected abstract String getNewGCName();
|
||||
|
||||
protected abstract String getNormalGCName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ public enum GCProvider {
|
|||
} else if (name.equals("MarkSweepCompact")) {
|
||||
// Serial collector ( -XX:+UseSerialGC )
|
||||
return new SerialGCModule(beans);
|
||||
} else if (name.indexOf("ZGC") > -1) {
|
||||
// Serial collector ( -XX:+UseZGC )
|
||||
return new ZGCModule(beans);
|
||||
} else {
|
||||
// Unknown
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -36,4 +36,9 @@ public class ParallelGCModule extends GCModule {
|
|||
return "PS Scavenge";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNormalGCName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,4 +35,9 @@ public class SerialGCModule extends GCModule {
|
|||
protected String getNewGCName() {
|
||||
return "Copy";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNormalGCName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.agent.core.jvm.gc;
|
||||
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.util.List;
|
||||
|
||||
public class ZGCModule extends GCModule {
|
||||
|
||||
public ZGCModule(List<GarbageCollectorMXBean> beans) {
|
||||
super(beans);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getOldGCName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNewGCName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getNormalGCName() {
|
||||
return "ZGC";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue