Skip to content

Commit

Permalink
Display memory pool pinpoint-apm#628
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidmalina committed Dec 2, 2015
1 parent 78b3374 commit e2bab00
Show file tree
Hide file tree
Showing 8 changed files with 717 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,34 @@ public final class MetricMonitorValues {
public static final String JVM_MEMORY_TOTAL_USED = JVM_MEMORY + ".total.used";
public static final String JVM_MEMORY_TOTAL_COMMITTED = JVM_MEMORY + ".total.committed";
public static final String JVM_MEMORY_TOTAL_MAX = JVM_MEMORY + ".total.max";
// Serial collector
// Serial collector ( -XX:+UseSerialGC )
public static final String JVM_MEMORY_POOLS_CODE_CACHE = JVM_MEMORY + ".pools.Code-Cache.usage";
public static final String JVM_MEMORY_POOLS_EDEN = JVM_MEMORY + ".pools.Eden-Space.usage";
public static final String JVM_MEMORY_POOLS_PERMGEN = JVM_MEMORY + ".pools.Perm-Gen.usage";
public static final String JVM_MEMORY_POOLS_OLDGEN = JVM_MEMORY + ".pools.Tenured-Gen.usage";
public static final String JVM_MEMORY_POOLS_SURVIVOR = JVM_MEMORY + ".pools.Survivor-Space.usage";
public static final String JVM_MEMORY_POOLS_TENURED = JVM_MEMORY + ".pools.Tenured-Gen.usage";
// Parallel (Old) collector
public static final String JVM_MEMORY_POOLS_PERMGEN = JVM_MEMORY + ".pools.Perm-Gen.usage";
public static final String JVM_MEMORY_POOLS_METASPACE = JVM_MEMORY + ".pools.Metaspace.usage";
// Parallel (Old) collector ( -XX:+UseParallelOldGC )
public static final String JVM_MEMORY_POOLS_PS_CODE_CACHE = JVM_MEMORY + ".pools.Code-Cache.usage";
public static final String JVM_MEMORY_POOLS_PS_EDEN = JVM_MEMORY + ".pools.PS-Eden-Space.usage";
public static final String JVM_MEMORY_POOLS_PS_OLDGEN = JVM_MEMORY + ".pools.PS-Old-Gen.usage";
public static final String JVM_MEMORY_POOLS_PS_PERMGEN = JVM_MEMORY + ".pools.PS-Perm-Gen.usage";
public static final String JVM_MEMORY_POOLS_PS_SURVIVOR = JVM_MEMORY + ".pools.PS-Survivor-Space.usage";
// CMS collector
public static final String JVM_MEMORY_POOLS_PS_PERMGEN = JVM_MEMORY + ".pools.PS-Perm-Gen.usage";
public static final String JVM_MEMORY_POOLS_PS_METASPACE = JVM_MEMORY + ".pools.Metaspace.usage";
// CMS collector ( -XX:+UseConcMarkSweepGC )
public static final String JVM_MEMORY_POOLS_CMS_CODE_CACHE = JVM_MEMORY + ".pools.Code-Cache.usage";
public static final String JVM_MEMORY_POOLS_CMS_EDEN = JVM_MEMORY + ".pools.Par-Eden-Space.usage";
public static final String JVM_MEMORY_POOLS_CMS_OLDGEN = JVM_MEMORY + ".pools.CMS-Old-Gen.usage";
public static final String JVM_MEMORY_POOLS_CMS_SURVIVOR = JVM_MEMORY + ".pools.Par-Survivor-Space.usage";
public static final String JVM_MEMORY_POOLS_CMS_PERMGEN = JVM_MEMORY + ".pools.CMS-Perm-Gen.usage";
public static final String JVM_MEMORY_POOLS_CODECACHE = JVM_MEMORY + ".pools.Code-Cache.usage";
public static final String JVM_MEMORY_POOLS_PAREDEN = JVM_MEMORY + ".pools.Par-Eden-Space.usage";
public static final String JVM_MEMORY_POOLS_PARSURVIVOR = JVM_MEMORY + ".pools.Par-Survivor-Space.usage";
// G1 collector
public static final String JVM_MEMORY_POOLS_CMS_METASPACE = JVM_MEMORY + ".pools.Metaspace.usage";
// G1 collector ( -XX:+UseG1GC )
public static final String JVM_MEMORY_POOLS_G1_CODE_CACHE = JVM_MEMORY + ".pools.Code-Cache.usage";
public static final String JVM_MEMORY_POOLS_G1_EDEN = JVM_MEMORY + ".pools.G1-Eden-Space.usage";
public static final String JVM_MEMORY_POOLS_G1_OLDGEN = JVM_MEMORY + ".pools.G1-Old-Gen.usage";
public static final String JVM_MEMORY_POOLS_G1_PERMGEN = JVM_MEMORY + ".pools.G1-Perm-Gen.usage";
public static final String JVM_MEMORY_POOLS_G1_SURVIVOR = JVM_MEMORY + ".pools.G1-Survivor-Space.usage";
public static final String JVM_MEMORY_POOLS_G1_PERMGEN = JVM_MEMORY + ".pools.G1-Perm-Gen.usage";
public static final String JVM_MEMORY_POOLS_G1_METASPACE = JVM_MEMORY + ".pools.Metaspace.usage";

public static final String CPU_LOAD = "cpu.load";
// CPU Load (JVM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
*
* @author emeroad
* @author harebox
* @author dawidmalina
*/
public class CmsCollector implements GarbageCollector {


public static final TJvmGcType GC_TYPE = TJvmGcType.CMS;

private final Gauge<Long> heapMax;
Expand All @@ -43,6 +43,13 @@ public class CmsCollector implements GarbageCollector {
private final Gauge<Long> heapNonHeapMax;
private final Gauge<Long> heapNonHeapUsed;

private final Gauge<Long> codeCacheUsage;
private final Gauge<Long> edenSpaceUsage;
private final Gauge<Long> oldGenUsage;
private final Gauge<Long> survivorSpaceUsage;
private final Gauge<Long> permGenUsage;
private final Gauge<Long> metaspaceUsage;

private final Gauge<Long> gcCount;
private final Gauge<Long> gcTime;

Expand All @@ -52,6 +59,7 @@ public CmsCollector(MetricMonitorRegistry registry) {
}

final MetricRegistry metricRegistry = registry.getRegistry();
@SuppressWarnings("rawtypes")
final SortedMap<String, Gauge> gauges = metricRegistry.getGauges();

this.heapMax = getLongGauge(gauges, JVM_MEMORY_HEAP_MAX);
Expand All @@ -60,30 +68,42 @@ public CmsCollector(MetricMonitorRegistry registry) {
this.heapNonHeapMax = getLongGauge(gauges, JVM_MEMORY_NONHEAP_MAX);
this.heapNonHeapUsed = getLongGauge(gauges, JVM_MEMORY_NONHEAP_USED);

this.codeCacheUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_CMS_CODE_CACHE);
this.edenSpaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_CMS_EDEN);
this.oldGenUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_CMS_OLDGEN);
this.survivorSpaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_CMS_SURVIVOR);
this.permGenUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_CMS_PERMGEN);
this.metaspaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_CMS_METASPACE);

this.gcCount = getLongGauge(gauges, JVM_GC_CMS_COUNT);
this.gcTime = getLongGauge(gauges, JVM_GC_CMS_TIME);

}

@Override
public int getTypeCode() {
return GC_TYPE.getValue();
return GC_TYPE.ordinal();
}

@Override
public TJvmGc collect() {

TJvmGc gc = new TJvmGc();
final TJvmGc gc = new TJvmGc();
gc.setType(GC_TYPE);
gc.setJvmMemoryHeapMax(heapMax.getValue());
gc.setJvmMemoryHeapUsed(heapUsed.getValue());

gc.setJvmMemoryNonHeapMax(heapNonHeapMax.getValue());
gc.setJvmMemoryNonHeapUsed(heapNonHeapUsed.getValue());

gc.setJvmPoolCodeCacheUsage(codeCacheUsage.getValue());
gc.setJvmPoolEdenSpaceUsage(edenSpaceUsage.getValue());
gc.setJvmPoolOldGenUsage(oldGenUsage.getValue());
gc.setJvmPoolSurvivorSpaceUsage(survivorSpaceUsage.getValue());
gc.setJvmPoolPermGenUsage(permGenUsage.getValue()); // can be null for jvm >= 1.8
gc.setJvmPoolMetaspaceUsage(metaspaceUsage.getValue()); // can be null for jvm < 1.8

gc.setJvmGcOldCount(gcCount.getValue());
gc.setJvmGcOldTime(gcTime.getValue());

return gc;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* @author emeroad
* @author harebox
* @author dawidmalina
*/
public class G1Collector implements GarbageCollector {

Expand All @@ -42,15 +43,23 @@ public class G1Collector implements GarbageCollector {
private final Gauge<Long> heapNonHeapMax;
private final Gauge<Long> heapNonHeapUsed;

private final Gauge<Long> codeCacheUsage;
private final Gauge<Long> edenSpaceUsage;
private final Gauge<Long> oldGenUsage;
private final Gauge<Long> survivorSpaceUsage;
private final Gauge<Long> permGenUsage;
private final Gauge<Long> metaspaceUsage;

private final Gauge<Long> gcCount;
private final Gauge<Long> gcTime;


public G1Collector(MetricMonitorRegistry registry) {
if (registry == null) {
throw new NullPointerException("registry must not be null");
}

final MetricRegistry metricRegistry = registry.getRegistry();
@SuppressWarnings("rawtypes")
final SortedMap<String, Gauge> gauges = metricRegistry.getGauges();

this.heapMax = getLongGauge(gauges, JVM_MEMORY_HEAP_MAX);
Expand All @@ -59,6 +68,13 @@ public G1Collector(MetricMonitorRegistry registry) {
this.heapNonHeapMax = getLongGauge(gauges, JVM_MEMORY_NONHEAP_MAX);
this.heapNonHeapUsed = getLongGauge(gauges, JVM_MEMORY_NONHEAP_USED);

this.codeCacheUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_G1_CODE_CACHE);
this.edenSpaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_G1_EDEN);
this.oldGenUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_G1_OLDGEN);
this.survivorSpaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_G1_SURVIVOR);
this.permGenUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_G1_PERMGEN);
this.metaspaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_G1_METASPACE);

this.gcCount = getLongGauge(gauges, JVM_GC_G1_OLD_COUNT);
this.gcTime = getLongGauge(gauges, JVM_GC_G1_OLD_TIME);
}
Expand All @@ -79,6 +95,13 @@ public TJvmGc collect() {
gc.setJvmMemoryNonHeapMax(heapNonHeapMax.getValue());
gc.setJvmMemoryNonHeapUsed(heapNonHeapUsed.getValue());

gc.setJvmPoolCodeCacheUsage(codeCacheUsage.getValue());
gc.setJvmPoolEdenSpaceUsage(edenSpaceUsage.getValue());
gc.setJvmPoolOldGenUsage(oldGenUsage.getValue());
gc.setJvmPoolSurvivorSpaceUsage(survivorSpaceUsage.getValue());
gc.setJvmPoolPermGenUsage(permGenUsage.getValue()); // can be null for jvm >= 1.8
gc.setJvmPoolMetaspaceUsage(metaspaceUsage.getValue()); // can be null for jvm < 1.8

gc.setJvmGcOldCount(gcCount.getValue());
gc.setJvmGcOldTime(gcTime.getValue());
return gc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* @author emeroad
* @author harebox
* @author dawidmalina
*/
public class ParallelCollector implements GarbageCollector {

Expand All @@ -42,14 +43,23 @@ public class ParallelCollector implements GarbageCollector {
private final Gauge<Long> heapNonHeapMax;
private final Gauge<Long> heapNonHeapUsed;

private final Gauge<Long> codeCacheUsage;
private final Gauge<Long> edenSpaceUsage;
private final Gauge<Long> oldGenUsage;
private final Gauge<Long> survivorSpaceUsage;
private final Gauge<Long> permGenUsage;
private final Gauge<Long> metaspaceUsage;

private final Gauge<Long> gcCount;
private final Gauge<Long> gcTime;

public ParallelCollector(MetricMonitorRegistry registry) {
if (registry == null) {
throw new NullPointerException("registry must not be null");
}

final MetricRegistry metricRegistry = registry.getRegistry();
@SuppressWarnings("rawtypes")
final SortedMap<String, Gauge> gauges = metricRegistry.getGauges();

this.heapMax = getLongGauge(gauges, JVM_MEMORY_HEAP_MAX);
Expand All @@ -58,6 +68,13 @@ public ParallelCollector(MetricMonitorRegistry registry) {
this.heapNonHeapMax = getLongGauge(gauges, JVM_MEMORY_NONHEAP_MAX);
this.heapNonHeapUsed = getLongGauge(gauges, JVM_MEMORY_NONHEAP_USED);

this.codeCacheUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_PS_CODE_CACHE);
this.edenSpaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_PS_EDEN);
this.oldGenUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_PS_OLDGEN);
this.survivorSpaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_PS_SURVIVOR);
this.permGenUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_PS_PERMGEN);
this.metaspaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_PS_METASPACE);

this.gcCount = getLongGauge(gauges, JVM_GC_PS_MS_COUNT);
this.gcTime = getLongGauge(gauges, JVM_GC_PS_MS_TIME);
}
Expand All @@ -78,6 +95,13 @@ public TJvmGc collect() {
gc.setJvmMemoryNonHeapMax(heapNonHeapMax.getValue());
gc.setJvmMemoryNonHeapUsed(heapNonHeapUsed.getValue());

gc.setJvmPoolCodeCacheUsage(codeCacheUsage.getValue());
gc.setJvmPoolEdenSpaceUsage(edenSpaceUsage.getValue());
gc.setJvmPoolOldGenUsage(oldGenUsage.getValue());
gc.setJvmPoolSurvivorSpaceUsage(survivorSpaceUsage.getValue());
gc.setJvmPoolPermGenUsage(permGenUsage.getValue()); // can be null for jvm >= 1.8
gc.setJvmPoolMetaspaceUsage(metaspaceUsage.getValue()); // can be null for jvm < 1.8

gc.setJvmGcOldCount(gcCount.getValue());
gc.setJvmGcOldTime(gcTime.getValue());
return gc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* @author emeroad
* @author harebox
* @author dawidmalina
*/
public class SerialCollector implements GarbageCollector {

Expand All @@ -42,6 +43,13 @@ public class SerialCollector implements GarbageCollector {
private final Gauge<Long> heapNonHeapMax;
private final Gauge<Long> heapNonHeapUsed;

private final Gauge<Long> codeCacheUsage;
private final Gauge<Long> edenSpaceUsage;
private final Gauge<Long> oldGenUsage;
private final Gauge<Long> survivorSpaceUsage;
private final Gauge<Long> permGenUsage;
private final Gauge<Long> metaspaceUsage;

private final Gauge<Long> gcCount;
private final Gauge<Long> gcTime;

Expand All @@ -51,6 +59,7 @@ public SerialCollector(MetricMonitorRegistry registry) {
}

final MetricRegistry metricRegistry = registry.getRegistry();
@SuppressWarnings("rawtypes")
final SortedMap<String, Gauge> gauges = metricRegistry.getGauges();

this.heapMax = getLongGauge(gauges, JVM_MEMORY_HEAP_MAX);
Expand All @@ -59,6 +68,13 @@ public SerialCollector(MetricMonitorRegistry registry) {
this.heapNonHeapMax = getLongGauge(gauges, JVM_MEMORY_NONHEAP_MAX);
this.heapNonHeapUsed = getLongGauge(gauges, JVM_MEMORY_NONHEAP_USED);

this.codeCacheUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_CODE_CACHE);
this.edenSpaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_EDEN);
this.oldGenUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_OLDGEN);
this.survivorSpaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_SURVIVOR);
this.permGenUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_PERMGEN);
this.metaspaceUsage = getLongGauge(gauges, JVM_MEMORY_POOLS_METASPACE);

this.gcCount = getLongGauge(gauges, JVM_GC_SERIAL_MSC_COUNT);
this.gcTime = getLongGauge(gauges, JVM_GC_SERIAL_MSC_TIME);
}
Expand All @@ -79,6 +95,13 @@ public TJvmGc collect() {
gc.setJvmMemoryNonHeapMax(heapNonHeapMax.getValue());
gc.setJvmMemoryNonHeapUsed(heapNonHeapUsed.getValue());

gc.setJvmPoolCodeCacheUsage(codeCacheUsage.getValue());
gc.setJvmPoolEdenSpaceUsage(edenSpaceUsage.getValue());
gc.setJvmPoolOldGenUsage(oldGenUsage.getValue());
gc.setJvmPoolSurvivorSpaceUsage(survivorSpaceUsage.getValue());
gc.setJvmPoolPermGenUsage(permGenUsage.getValue()); // can be null for jvm >= 1.8
gc.setJvmPoolMetaspaceUsage(metaspaceUsage.getValue()); // can be null for jvm < 1.8

gc.setJvmGcOldCount(gcCount.getValue());
gc.setJvmGcOldTime(gcTime.getValue());
return gc;
Expand Down
Binary file added thrift/src/compiler/linux/thrift-0.9.2
Binary file not shown.
Loading

0 comments on commit e2bab00

Please # to comment.