mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-17 00:36:02 +10:00
[김훈민] [PINPOINT-213] 수집하는 데이터 줄임. GC 통계를 일반화. AgentStat에 다른 종류의 통계가 들어갈 수 있도록 수정.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@2724 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -78,16 +78,22 @@ public class AgentStatMonitor {
|
||||
// FIXME 설정에 따라 어떤 데이터를 수집할 지 선택할 수 있도록 해야한다. 여기서는 JVM 메모리 정보를 default로 수집.
|
||||
this.monitorRegistry.registerJvmMemoryMonitor(new MonitorName(MetricMonitorValues.JVM_MEMORY));
|
||||
this.monitorRegistry.registerJvmGcMonitor(new MonitorName(MetricMonitorValues.JVM_GC));
|
||||
|
||||
this.agentStat = new TAgentStat();
|
||||
|
||||
// TAgentStat 객체를 준비한다.
|
||||
this.agentStat = new TAgentStat();
|
||||
this.agentStat.setAgentId(agentId);
|
||||
|
||||
// GarbageCollector 타입을 확인한다.
|
||||
this.garbageCollector = new GarbageCollector();
|
||||
this.garbageCollector.setType(monitorRegistry);
|
||||
logger.info("found : {}", this.garbageCollector);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("found : {}", this.garbageCollector);
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
agentStat.setTimestamp(System.currentTimeMillis());
|
||||
garbageCollector.map(monitorRegistry, agentStat, agentId);
|
||||
dataSender.send(agentStat);
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -7,8 +7,6 @@ import com.codahale.metrics.MetricRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* FIXME 이대로 괜찮은가 -ㅁ-;
|
||||
*
|
||||
* @author harebox
|
||||
*/
|
||||
public class MetricMonitorValues {
|
||||
@@ -47,9 +45,9 @@ public class MetricMonitorValues {
|
||||
public static final String JVM_MEMORY_NONHEAP_COMMITTED = JVM_MEMORY + ".non-heap.committed";
|
||||
public static final String JVM_MEMORY_NONHEAP_MAX = JVM_MEMORY + ".non-heap.max";
|
||||
public static final String JVM_MEMORY_TOTAL_INIT = JVM_MEMORY + ".total.init";
|
||||
public static final String JVM_MEMORY_TOTAL_USED = JVM_MEMORY + ".total.max";
|
||||
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.used";
|
||||
public static final String JVM_MEMORY_TOTAL_MAX = JVM_MEMORY + ".total.max";
|
||||
// Serial collector
|
||||
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";
|
||||
|
||||
@@ -2,25 +2,17 @@ package com.nhn.pinpoint.profiler.monitor.codahale.gc;
|
||||
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_GC_CMS_COUNT;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_GC_CMS_TIME;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_GC_PARNEW_COUNT;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_GC_PARNEW_TIME;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_HEAP_MAX;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_HEAP_USED;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_NONHEAP_MAX;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_NONHEAP_USED;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_POOLS_CMS_OLDGEN;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_POOLS_CMS_PERMGEN;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_POOLS_CODECACHE;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_POOLS_PAREDEN;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_POOLS_PARSURVIVOR;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_TOTAL_MAX;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_TOTAL_USED;
|
||||
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorRegistry;
|
||||
import com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentStat;
|
||||
import com.nhn.pinpoint.thrift.dto.TStatWithCmsCollector;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGc;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGcType;
|
||||
|
||||
/**
|
||||
* HotSpot's Concurrent-Mark-Sweep collector
|
||||
@@ -35,30 +27,20 @@ public class CmsCollector extends GarbageCollectorType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void map(MetricMonitorRegistry registry, TAgentStat agentStat, Object typeObject, String agentId) {
|
||||
public void map(MetricMonitorRegistry registry, TAgentStat agentStat, String agentId) {
|
||||
MetricRegistry r = registry.getRegistry();
|
||||
TStatWithCmsCollector stat = (TStatWithCmsCollector) typeObject;
|
||||
if (stat == null) {
|
||||
stat = new TStatWithCmsCollector();
|
||||
agentStat.setCms(stat);
|
||||
TJvmGc gc = agentStat.getGc();
|
||||
if (gc == null) {
|
||||
gc = new TJvmGc();
|
||||
agentStat.setGc(gc);
|
||||
}
|
||||
stat.setAgentId(agentId);
|
||||
stat.setTimestamp(System.currentTimeMillis());
|
||||
stat.setJvmMemoryTotalMax(MetricMonitorValues.getLong(r, JVM_MEMORY_TOTAL_MAX));
|
||||
stat.setJvmMemoryTotalUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_TOTAL_USED));
|
||||
stat.setJvmMemoryHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_MAX));
|
||||
stat.setJvmMemoryHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_USED));
|
||||
stat.setJvmMemoryNonHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_MAX));
|
||||
stat.setJvmMemoryNonHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_USED));
|
||||
stat.setJvmMemoryPoolsCodeCacheUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_CODECACHE));
|
||||
stat.setJvmMemoryPoolsParEdenSpaceUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_PAREDEN));
|
||||
stat.setJvmMemoryPoolsParSurvivorSpaceUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_PARSURVIVOR));
|
||||
stat.setJvmMemoryPoolsCMSOldGenUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_CMS_OLDGEN));
|
||||
stat.setJvmMemoryPoolsCMSPermGenUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_CMS_PERMGEN));
|
||||
stat.setJvmGcCmsCount(MetricMonitorValues.getLong(r, JVM_GC_CMS_COUNT));
|
||||
stat.setJvmGcCmsTime(MetricMonitorValues.getLong(r, JVM_GC_CMS_TIME));
|
||||
stat.setJvmGcParNewCount(MetricMonitorValues.getLong(r, JVM_GC_PARNEW_COUNT));
|
||||
stat.setJvmGcParNewTime(MetricMonitorValues.getLong(r, JVM_GC_PARNEW_TIME));
|
||||
gc.setType(TJvmGcType.CMS);
|
||||
gc.setJvmMemoryHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_MAX));
|
||||
gc.setJvmMemoryHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_USED));
|
||||
gc.setJvmMemoryNonHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_MAX));
|
||||
gc.setJvmMemoryNonHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_USED));
|
||||
gc.setJvmGcOldCount(MetricMonitorValues.getLong(r, JVM_GC_CMS_COUNT));
|
||||
gc.setJvmGcOldTime(MetricMonitorValues.getLong(r, JVM_GC_CMS_TIME));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,8 @@ import com.codahale.metrics.MetricRegistry;
|
||||
import com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorRegistry;
|
||||
import com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentStat;
|
||||
import com.nhn.pinpoint.thrift.dto.TStatWithG1Collector;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGc;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGcType;
|
||||
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.*;
|
||||
|
||||
@@ -21,30 +22,20 @@ public class G1Collector extends GarbageCollectorType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void map(MetricMonitorRegistry registry, TAgentStat agentStat, Object typeObject, String agentId) {
|
||||
public void map(MetricMonitorRegistry registry, TAgentStat agentStat, String agentId) {
|
||||
MetricRegistry r = registry.getRegistry();
|
||||
TStatWithG1Collector stat = (TStatWithG1Collector) typeObject;
|
||||
if (stat == null) {
|
||||
stat = new TStatWithG1Collector();
|
||||
agentStat.setG1(stat);
|
||||
TJvmGc gc = agentStat.getGc();
|
||||
if (gc == null) {
|
||||
gc = new TJvmGc();
|
||||
agentStat.setGc(gc);
|
||||
}
|
||||
stat.setAgentId(agentId);
|
||||
stat.setTimestamp(System.currentTimeMillis());
|
||||
stat.setJvmMemoryTotalMax(MetricMonitorValues.getLong(r, JVM_MEMORY_TOTAL_MAX));
|
||||
stat.setJvmMemoryTotalUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_TOTAL_USED));
|
||||
stat.setJvmMemoryHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_MAX));
|
||||
stat.setJvmMemoryHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_USED));
|
||||
stat.setJvmMemoryNonHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_MAX));
|
||||
stat.setJvmMemoryNonHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_USED));
|
||||
stat.setJvmMemoryPoolsCodeCacheUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_CODECACHE));
|
||||
stat.setJvmMemoryPoolsG1EdenSpaceUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_G1_EDEN));
|
||||
stat.setJvmMemoryPoolsG1SurvivorSpaceUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_G1_SURVIVOR));
|
||||
stat.setJvmMemoryPoolsG1OldGenUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_G1_OLDGEN));
|
||||
stat.setJvmMemoryPoolsG1PermGenUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_G1_PERMGEN));
|
||||
stat.setJvmGcG1OldGenerationCount(MetricMonitorValues.getLong(r, JVM_GC_G1_OLD_COUNT));
|
||||
stat.setJvmGcG1OldGenerationTime(MetricMonitorValues.getLong(r, JVM_GC_G1_OLD_TIME));
|
||||
stat.setJvmGcG1YoungGenerationCount(MetricMonitorValues.getLong(r, JVM_GC_G1_YOUNG_COUNT));
|
||||
stat.setJvmGcG1YoungGenerationTime(MetricMonitorValues.getLong(r, JVM_GC_G1_YOUNG_TIME));
|
||||
gc.setType(TJvmGcType.G1);
|
||||
gc.setJvmMemoryHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_MAX));
|
||||
gc.setJvmMemoryHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_USED));
|
||||
gc.setJvmMemoryNonHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_MAX));
|
||||
gc.setJvmMemoryNonHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_USED));
|
||||
gc.setJvmGcOldCount(MetricMonitorValues.getLong(r, JVM_GC_G1_OLD_COUNT));
|
||||
gc.setJvmGcOldTime(MetricMonitorValues.getLong(r, JVM_GC_G1_OLD_TIME));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,13 +39,7 @@ public class GarbageCollector {
|
||||
throw new NullPointerException("agentId must not be null");
|
||||
}
|
||||
|
||||
Object typeObject = null;
|
||||
|
||||
if (agentStat.getSetField() != null) {
|
||||
typeObject = agentStat.getFieldValue(agentStat.getSetField());
|
||||
}
|
||||
|
||||
type.map(registry, agentStat, typeObject, agentId);
|
||||
type.map(registry, agentStat, agentId);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
+6
-5
@@ -4,6 +4,7 @@ import java.util.Collection;
|
||||
|
||||
import com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorRegistry;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentStat;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGcType;
|
||||
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.*;
|
||||
|
||||
@@ -14,7 +15,7 @@ public abstract class GarbageCollectorType {
|
||||
|
||||
abstract public int getTypeCode();
|
||||
|
||||
abstract public void map(MetricMonitorRegistry registry, TAgentStat agentStat, Object typeObject, String agentId);
|
||||
abstract public void map(MetricMonitorRegistry registry, TAgentStat agentStat, String agentId);
|
||||
|
||||
/**
|
||||
* 타입 코드로 생성
|
||||
@@ -52,9 +53,9 @@ public abstract class GarbageCollectorType {
|
||||
}
|
||||
|
||||
// FIXME AgentStat 자체를 타입으로 써도 되지만 일단 이렇게 해둔다.
|
||||
public static final int SERIAL_COLLECTOR = TAgentStat._Fields.SERIAL.ordinal();
|
||||
public static final int PARALLEL_COLLECTOR = TAgentStat._Fields.PARALLEL.ordinal();
|
||||
public static final int CMS_COLLECTOR = TAgentStat._Fields.CMS.ordinal();
|
||||
public static final int G1_COLLECTOR = TAgentStat._Fields.G1.ordinal();
|
||||
public static final int SERIAL_COLLECTOR = TJvmGcType.SERIAL.ordinal();
|
||||
public static final int PARALLEL_COLLECTOR = TJvmGcType.PARALLEL.ordinal();
|
||||
public static final int CMS_COLLECTOR = TJvmGcType.CMS.ordinal();
|
||||
public static final int G1_COLLECTOR = TJvmGcType.G1.ordinal();
|
||||
|
||||
}
|
||||
|
||||
+21
-25
@@ -1,12 +1,18 @@
|
||||
package com.nhn.pinpoint.profiler.monitor.codahale.gc;
|
||||
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_GC_PS_MS_COUNT;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_GC_PS_MS_TIME;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_HEAP_MAX;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_HEAP_USED;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_NONHEAP_MAX;
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.JVM_MEMORY_NONHEAP_USED;
|
||||
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorRegistry;
|
||||
import com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentStat;
|
||||
import com.nhn.pinpoint.thrift.dto.TStatWithParallelCollector;
|
||||
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.*;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGc;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGcType;
|
||||
|
||||
/**
|
||||
* HotSpot's Parallel (Old) collector
|
||||
@@ -21,30 +27,20 @@ public class ParallelCollector extends GarbageCollectorType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void map(MetricMonitorRegistry registry, TAgentStat agentStat, Object typeObject, String agentId) {
|
||||
public void map(MetricMonitorRegistry registry, TAgentStat agentStat, String agentId) {
|
||||
MetricRegistry r = registry.getRegistry();
|
||||
TStatWithParallelCollector stat = (TStatWithParallelCollector) typeObject;
|
||||
if (stat == null) {
|
||||
stat = new TStatWithParallelCollector();
|
||||
agentStat.setParallel(stat);
|
||||
TJvmGc gc = agentStat.getGc();
|
||||
if (gc == null) {
|
||||
gc = new TJvmGc();
|
||||
agentStat.setGc(gc);
|
||||
}
|
||||
stat.setAgentId(agentId);
|
||||
stat.setTimestamp(System.currentTimeMillis());
|
||||
stat.setJvmMemoryTotalMax(MetricMonitorValues.getLong(r, JVM_MEMORY_TOTAL_MAX));
|
||||
stat.setJvmMemoryTotalUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_TOTAL_USED));
|
||||
stat.setJvmMemoryHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_MAX));
|
||||
stat.setJvmMemoryHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_USED));
|
||||
stat.setJvmMemoryNonHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_MAX));
|
||||
stat.setJvmMemoryNonHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_USED));
|
||||
stat.setJvmMemoryPoolsCodeCacheUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_CODECACHE));
|
||||
stat.setJvmMemoryPoolsPSEdenSpaceUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_PS_EDEN));
|
||||
stat.setJvmMemoryPoolsPSSurvivorSpaceUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_PS_SURVIVOR));
|
||||
stat.setJvmMemoryPoolsPSOldGenUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_PS_OLDGEN));
|
||||
stat.setJvmMemoryPoolsPSPermGenUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_PS_PERMGEN));
|
||||
stat.setJvmGcPSMarkSweepCount(MetricMonitorValues.getLong(r, JVM_GC_PS_MS_COUNT));
|
||||
stat.setJvmGcPSMarkSweepTime(MetricMonitorValues.getLong(r, JVM_GC_PS_MS_TIME));
|
||||
stat.setJvmGcPSScavengeCount(MetricMonitorValues.getLong(r, JVM_GC_PS_SCAVENGE_COUNT));
|
||||
stat.setJvmGcPSMarkSweepTime(MetricMonitorValues.getLong(r, JVM_GC_PS_SCAVENGE_TIME));
|
||||
gc.setType(TJvmGcType.PARALLEL);
|
||||
gc.setJvmMemoryHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_MAX));
|
||||
gc.setJvmMemoryHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_USED));
|
||||
gc.setJvmMemoryNonHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_MAX));
|
||||
gc.setJvmMemoryNonHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_USED));
|
||||
gc.setJvmGcOldCount(MetricMonitorValues.getLong(r, JVM_GC_PS_MS_COUNT));
|
||||
gc.setJvmGcOldTime(MetricMonitorValues.getLong(r, JVM_GC_PS_MS_TIME));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,8 @@ import com.codahale.metrics.MetricRegistry;
|
||||
import com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorRegistry;
|
||||
import com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues;
|
||||
import com.nhn.pinpoint.thrift.dto.TAgentStat;
|
||||
import com.nhn.pinpoint.thrift.dto.TStatWithSerialCollector;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGc;
|
||||
import com.nhn.pinpoint.thrift.dto.TJvmGcType;
|
||||
|
||||
import static com.nhn.pinpoint.profiler.monitor.codahale.MetricMonitorValues.*;
|
||||
|
||||
@@ -21,30 +22,20 @@ public class SerialCollector extends GarbageCollectorType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void map(MetricMonitorRegistry registry, TAgentStat agentStat, Object typeObject, String agentId) {
|
||||
public void map(MetricMonitorRegistry registry, TAgentStat agentStat, String agentId) {
|
||||
MetricRegistry r = registry.getRegistry();
|
||||
TStatWithSerialCollector stat = (TStatWithSerialCollector) typeObject;
|
||||
if (stat == null) {
|
||||
stat = new TStatWithSerialCollector();
|
||||
agentStat.setSerial(stat);
|
||||
TJvmGc gc = agentStat.getGc();
|
||||
if (gc == null) {
|
||||
gc = new TJvmGc();
|
||||
agentStat.setGc(gc);
|
||||
}
|
||||
stat.setAgentId(agentId);
|
||||
stat.setTimestamp(System.currentTimeMillis());
|
||||
stat.setJvmMemoryTotalMax(MetricMonitorValues.getLong(r, JVM_MEMORY_TOTAL_MAX));
|
||||
stat.setJvmMemoryTotalUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_TOTAL_USED));
|
||||
stat.setJvmMemoryHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_MAX));
|
||||
stat.setJvmMemoryHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_USED));
|
||||
stat.setJvmMemoryNonHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_MAX));
|
||||
stat.setJvmMemoryNonHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_USED));
|
||||
stat.setJvmMemoryPoolsCodeCacheUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_CODECACHE));
|
||||
stat.setJvmMemoryPoolsEdenSpaceUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_EDEN));
|
||||
stat.setJvmMemoryPoolsPermGenUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_PERMGEN));
|
||||
stat.setJvmMemoryPoolsSurvivorSpaceUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_SURVIVOR));
|
||||
stat.setJvmMemoryPoolsTenuredGenUsage(MetricMonitorValues.getLong(r, JVM_MEMORY_POOLS_TENURED));
|
||||
stat.setJvmGcCopyCount(MetricMonitorValues.getLong(r, JVM_GC_SERIAL_COPY_COUNT));
|
||||
stat.setJvmGcCopyTime(MetricMonitorValues.getLong(r, JVM_GC_SERIAL_COPY_TIME));
|
||||
stat.setJvmGcMarkSweepCompactCount(MetricMonitorValues.getLong(r, JVM_GC_SERIAL_MSC_COUNT));
|
||||
stat.setJvmGcMarkSweepCompactTime(MetricMonitorValues.getLong(r, JVM_GC_SERIAL_MSC_TIME));
|
||||
gc.setType(TJvmGcType.SERIAL);
|
||||
gc.setJvmMemoryHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_MAX));
|
||||
gc.setJvmMemoryHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_HEAP_USED));
|
||||
gc.setJvmMemoryNonHeapMax(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_MAX));
|
||||
gc.setJvmMemoryNonHeapUsed(MetricMonitorValues.getLong(r, JVM_MEMORY_NONHEAP_USED));
|
||||
gc.setJvmGcOldCount(MetricMonitorValues.getLong(r, JVM_GC_SERIAL_MSC_COUNT));
|
||||
gc.setJvmGcOldTime(MetricMonitorValues.getLong(r, JVM_GC_SERIAL_MSC_TIME));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ public class AgentStatMonitorTest {
|
||||
|
||||
@Test
|
||||
public void test() throws InterruptedException {
|
||||
System.out.println(System.currentTimeMillis());
|
||||
System.setProperty("pinpoint.log", ".");
|
||||
AgentStatMonitor monitor = new AgentStatMonitor(new LoggingDataSender(), "agentId");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user