From affcd6f9260799177624d8566fb35d6dfd9bb2ba Mon Sep 17 00:00:00 2001 From: Hoonmin Kim Date: Mon, 4 Nov 2013 02:10:09 +0000 Subject: [PATCH] =?UTF-8?q?[=EA=B9=80=ED=9B=88=EB=AF=BC]=20[PINPOINT-213]?= =?UTF-8?q?=20=EC=88=98=EC=A7=91=ED=95=98=EB=8A=94=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=A4=84=EC=9E=84.=20GC=20=ED=86=B5=EA=B3=84?= =?UTF-8?q?=EB=A5=BC=20=EC=9D=BC=EB=B0=98=ED=99=94.=20AgentStat=EC=97=90?= =?UTF-8?q?=20=EB=8B=A4=EB=A5=B8=20=EC=A2=85=EB=A5=98=EC=9D=98=20=ED=86=B5?= =?UTF-8?q?=EA=B3=84=EA=B0=80=20=EB=93=A4=EC=96=B4=EA=B0=88=20=EC=88=98=20?= =?UTF-8?q?=EC=9E=88=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@2724 84d0f5b1-2673-498c-a247-62c4ff18d310 --- .../profiler/monitor/AgentStatMonitor.java | 12 +++-- .../monitor/codahale/MetricMonitorValues.java | 6 +-- .../monitor/codahale/gc/CmsCollector.java | 46 ++++++------------- .../monitor/codahale/gc/G1Collector.java | 37 ++++++--------- .../monitor/codahale/gc/GarbageCollector.java | 8 +--- .../codahale/gc/GarbageCollectorType.java | 11 +++-- .../codahale/gc/ParallelCollector.java | 46 +++++++++---------- .../monitor/codahale/gc/SerialCollector.java | 37 ++++++--------- .../monitor/AgentStatMonitorTest.java | 1 + 9 files changed, 82 insertions(+), 122 deletions(-) diff --git a/src/main/java/com/nhn/pinpoint/profiler/monitor/AgentStatMonitor.java b/src/main/java/com/nhn/pinpoint/profiler/monitor/AgentStatMonitor.java index 599ec07ba..5b008975f 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/monitor/AgentStatMonitor.java +++ b/src/main/java/com/nhn/pinpoint/profiler/monitor/AgentStatMonitor.java @@ -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) { diff --git a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/MetricMonitorValues.java b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/MetricMonitorValues.java index ac8b1122f..b191e2ce0 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/MetricMonitorValues.java +++ b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/MetricMonitorValues.java @@ -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"; diff --git a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/CmsCollector.java b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/CmsCollector.java index 3917a327b..7dbda88b0 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/CmsCollector.java +++ b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/CmsCollector.java @@ -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 diff --git a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/G1Collector.java b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/G1Collector.java index 281c72f55..c47b504c8 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/G1Collector.java +++ b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/G1Collector.java @@ -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 diff --git a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/GarbageCollector.java b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/GarbageCollector.java index 41f12936c..d0e1ccc1e 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/GarbageCollector.java +++ b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/GarbageCollector.java @@ -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() { diff --git a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/GarbageCollectorType.java b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/GarbageCollectorType.java index 81f678626..4dcf10235 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/GarbageCollectorType.java +++ b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/GarbageCollectorType.java @@ -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(); } diff --git a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/ParallelCollector.java b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/ParallelCollector.java index 147b27e65..babfb8e52 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/ParallelCollector.java +++ b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/ParallelCollector.java @@ -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 diff --git a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/SerialCollector.java b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/SerialCollector.java index 1785b40aa..060a0d216 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/SerialCollector.java +++ b/src/main/java/com/nhn/pinpoint/profiler/monitor/codahale/gc/SerialCollector.java @@ -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 diff --git a/src/test/java/com/nhn/pinpoint/profiler/monitor/AgentStatMonitorTest.java b/src/test/java/com/nhn/pinpoint/profiler/monitor/AgentStatMonitorTest.java index 7ea173b93..cb8cf13dd 100644 --- a/src/test/java/com/nhn/pinpoint/profiler/monitor/AgentStatMonitorTest.java +++ b/src/test/java/com/nhn/pinpoint/profiler/monitor/AgentStatMonitorTest.java @@ -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");