diff --git a/inspector-module/inspector-collector/pom.xml b/inspector-module/inspector-collector/pom.xml index 809f06a32796..a08229ffd668 100644 --- a/inspector-module/inspector-collector/pom.xml +++ b/inspector-module/inspector-collector/pom.xml @@ -19,6 +19,10 @@ + + com.navercorp.pinpoint + pinpoint-inspector-commons + com.navercorp.pinpoint pinpoint-collector @@ -55,5 +59,9 @@ provided + + com.navercorp.pinpoint + pinpoint-inspector-commons + \ No newline at end of file diff --git a/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/dao/pinot/DefaultAgentStatDao.java b/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/dao/pinot/DefaultAgentStatDao.java index 43d2faba5870..ec1b407e8fcf 100644 --- a/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/dao/pinot/DefaultAgentStatDao.java +++ b/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/dao/pinot/DefaultAgentStatDao.java @@ -55,8 +55,7 @@ public DefaultAgentStatDao(Function> dataPointFunction, Kaf public void insert(String agentId, List agentStatData) { List agentStatList = convertDataToKafkaModel(agentStatData); for (AgentStat agentStat : agentStatList) { - String kafkaKey = generateKafkaKey(agentStat); - kafkaAgentStatTemplate.send(topic, kafkaKey, agentStat); + kafkaAgentStatTemplate.send(topic, agentStat.getSortKey(), agentStat); } } @@ -71,14 +70,4 @@ public void dispatch(AgentStatBo agentStatBo) { List dataPointList = this.dataPointFunction.apply(agentStatBo); insert(agentStatBo.getAgentId(), dataPointList); } - - private String generateKafkaKey(AgentStat agentStat) { - StringBuilder sb = new StringBuilder(); - sb.append(agentStat.getApplicationName()); - sb.append("_"); - sb.append(agentStat.getAgentId()); - sb.append("_"); - sb.append(agentStat.getMetricName()); - return sb.toString(); - } } diff --git a/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/model/kafka/AgentStat.java b/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/model/kafka/AgentStat.java index 40cb9c04333b..0c5ee83d1aaa 100644 --- a/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/model/kafka/AgentStat.java +++ b/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/model/kafka/AgentStat.java @@ -30,22 +30,22 @@ public class AgentStat { private final String tenantId; + private final String sortKey; private final String applicationName; private final String agentId; - private final String metricName; private final String fieldName; private final double fieldValue; private final List tags; - private final long eventTime; - public AgentStat(String tenantId, String applicationName, String agentId, String metricName, String fieldName, double fieldValue, long eventTime) { - this(tenantId, applicationName, agentId, metricName, fieldName, fieldValue, eventTime, Collections.emptyList()); + public AgentStat(String tenantId, String sortKey, String applicationName, String agentId, String metricName, String fieldName, double fieldValue, long eventTime) { + this(tenantId, sortKey, applicationName, agentId, metricName, fieldName, fieldValue, eventTime, Collections.emptyList()); } - public AgentStat(String tenantId, String applicationName, String agentId, String metricName, String fieldName, double fieldValue, long eventTime, List tags) { + public AgentStat(String tenantId, String sortKey, String applicationName, String agentId, String metricName, String fieldName, double fieldValue, long eventTime, List tags) { this.tenantId = tenantId; + this.sortKey = sortKey; this.applicationName = applicationName; this.agentId = agentId; this.metricName = metricName; @@ -88,5 +88,9 @@ public List getTags() { return tags; } + public String getSortKey() { + return sortKey; + } + } diff --git a/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/model/kafka/AgentStatModelConverter.java b/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/model/kafka/AgentStatModelConverter.java index 451824fa8f33..8738438c4034 100644 --- a/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/model/kafka/AgentStatModelConverter.java +++ b/inspector-module/inspector-collector/src/main/java/com/navercorp/pinpoint/inspector/collector/model/kafka/AgentStatModelConverter.java @@ -16,6 +16,7 @@ package com.navercorp.pinpoint.inspector.collector.model.kafka; +import com.navercorp.pinpoint.common.model.SortKeyUtils; import com.navercorp.pinpoint.common.server.bo.stat.ActiveTraceBo; import com.navercorp.pinpoint.common.server.bo.stat.AgentStatDataPoint; import com.navercorp.pinpoint.common.server.bo.stat.AgentStatType; @@ -47,10 +48,11 @@ public class AgentStatModelConverter { public static List convertCpuLoadToAgentStat(List cpuLoadBoList, String tenantId) { List agentStatList = cpuLoadBoList.stream() .flatMap(cpuLoadBo -> { - AgentStat jvmCpuLoad = new AgentStat(tenantId, cpuLoadBo.getApplicationName(), cpuLoadBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(cpuLoadBo.getApplicationName(), cpuLoadBo.getAgentId(), AgentStatType.CPU_LOAD.getChartType()); + AgentStat jvmCpuLoad = new AgentStat(tenantId, sortKey, cpuLoadBo.getApplicationName(), cpuLoadBo.getAgentId(), AgentStatType.CPU_LOAD.getChartType(), AgentStatField.CPU_LOAD_JVM.getFieldName(), cpuLoadBo.getJvmCpuLoad(), cpuLoadBo.getTimestamp()); - AgentStat systemCpuLoad = new AgentStat(tenantId, cpuLoadBo.getApplicationName(), cpuLoadBo.getAgentId(), + AgentStat systemCpuLoad = new AgentStat(tenantId, sortKey, cpuLoadBo.getApplicationName(), cpuLoadBo.getAgentId(), AgentStatType.CPU_LOAD.getChartType(), AgentStatField.CPU_LOAD_SYSTEM.getFieldName(), cpuLoadBo.getSystemCpuLoad(), cpuLoadBo.getTimestamp()); @@ -64,16 +66,17 @@ public static List convertCpuLoadToAgentStat(List cpuLoadB public static List convertActiveTraceToAgentStat(List activeTraceBoList, String tenantId) { List agentStatList = activeTraceBoList.stream() .flatMap(activeTraceBo -> { - AgentStat fastCount = new AgentStat(tenantId, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), AgentStatType.ACTIVE_TRACE.getChartType()); + AgentStat fastCount = new AgentStat(tenantId, sortKey, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), AgentStatType.ACTIVE_TRACE.getChartType(), AgentStatField.ACTIVE_TRACE_FAST_COUNT.getFieldName(), activeTraceBo.getActiveTraceHistogram().getFastCount(), activeTraceBo.getTimestamp()); - AgentStat normalCount = new AgentStat(tenantId, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), + AgentStat normalCount = new AgentStat(tenantId, sortKey, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), AgentStatType.ACTIVE_TRACE.getChartType(), AgentStatField.ACTIVE_TRACE_NORNAL_COUNT.getFieldName(), activeTraceBo.getActiveTraceHistogram().getNormalCount(), activeTraceBo.getTimestamp()); - AgentStat slowCount = new AgentStat(tenantId, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), + AgentStat slowCount = new AgentStat(tenantId, sortKey, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), AgentStatType.ACTIVE_TRACE.getChartType(), AgentStatField.ACTIVE_TRACE_SLOW_COUNT.getFieldName(), activeTraceBo.getActiveTraceHistogram().getSlowCount(), activeTraceBo.getTimestamp()); - AgentStat verySlowCount = new AgentStat(tenantId, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), + AgentStat verySlowCount = new AgentStat(tenantId, sortKey, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), AgentStatType.ACTIVE_TRACE.getChartType(), AgentStatField.ACTIVE_TRACE_VERY_SLOW_COUNT.getFieldName(), activeTraceBo.getActiveTraceHistogram().getVerySlowCount(), activeTraceBo.getTimestamp()); @@ -81,7 +84,7 @@ public static List convertActiveTraceToAgentStat(List activeTraceBo.getActiveTraceHistogram().getNormalCount() + activeTraceBo.getActiveTraceHistogram().getSlowCount() + activeTraceBo.getActiveTraceHistogram().getVerySlowCount(); - AgentStat totalCount = new AgentStat(tenantId, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), + AgentStat totalCount = new AgentStat(tenantId, sortKey, activeTraceBo.getApplicationName(), activeTraceBo.getAgentId(), AgentStatType.ACTIVE_TRACE.getChartType(), AgentStatField.ACTIVE_TRACE_TOTAL_COUNT.getFieldName(), calculatedTotalCount, activeTraceBo.getTimestamp()); return Stream.of(fastCount, normalCount, slowCount, verySlowCount, totalCount); @@ -94,25 +97,26 @@ public static List convertActiveTraceToAgentStat(List public static List convertJvmGcToAgentStat(List jvmGcBoList, String tenantId) { List agentStatList = jvmGcBoList.stream() .flatMap(jvmGcBo -> { - AgentStat gcType = new AgentStat(tenantId, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), AgentStatType.JVM_GC.getChartType()); + AgentStat gcType = new AgentStat(tenantId, sortKey, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), AgentStatType.JVM_GC.getChartType(), AgentStatField.JVM_GC_TYPE.getFieldName(), jvmGcBo.getGcType().getTypeCode(), jvmGcBo.getTimestamp()); - AgentStat heapUsed = new AgentStat(tenantId, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), + AgentStat heapUsed = new AgentStat(tenantId, sortKey, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), AgentStatType.JVM_GC.getChartType(), AgentStatField.JVM_GC_HEAP_USED.getFieldName(), jvmGcBo.getHeapUsed(), jvmGcBo.getTimestamp()); - AgentStat heapMax = new AgentStat(tenantId, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), + AgentStat heapMax = new AgentStat(tenantId, sortKey, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), AgentStatType.JVM_GC.getChartType(), AgentStatField.JVM_GC_HEAP_MAX.getFieldName(), jvmGcBo.getHeapMax(), jvmGcBo.getTimestamp()); - AgentStat nonHeapUsed = new AgentStat(tenantId, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), + AgentStat nonHeapUsed = new AgentStat(tenantId, sortKey, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), AgentStatType.JVM_GC.getChartType(), AgentStatField.JVM_GC_NONHEAP_USED.getFieldName(), jvmGcBo.getNonHeapUsed(), jvmGcBo.getTimestamp()); - AgentStat nonHeapMax = new AgentStat(tenantId, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), + AgentStat nonHeapMax = new AgentStat(tenantId, sortKey, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), AgentStatType.JVM_GC.getChartType(), AgentStatField.JVM_GC_NONHEAP_MAX.getFieldName(), jvmGcBo.getNonHeapMax(), jvmGcBo.getTimestamp()); - AgentStat gcOldCount = new AgentStat(tenantId, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), + AgentStat gcOldCount = new AgentStat(tenantId, sortKey, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), AgentStatType.JVM_GC.getChartType(), AgentStatField.JVM_GC_NONHEAP_GC_OLD_COUNT.getFieldName(), jvmGcBo.getGcOldCount(), jvmGcBo.getTimestamp()); - AgentStat gcOldTime = new AgentStat(tenantId, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), + AgentStat gcOldTime = new AgentStat(tenantId, sortKey, jvmGcBo.getApplicationName(), jvmGcBo.getAgentId(), AgentStatType.JVM_GC.getChartType(), AgentStatField.JVM_GC_NONHEAP_GC_OLD_TIME.getFieldName(), jvmGcBo.getGcOldTime(), jvmGcBo.getTimestamp()); return Stream.of(gcType, heapUsed, heapMax, nonHeapUsed, @@ -128,28 +132,29 @@ public static List convertJvmGCDetailedToAgentStat(List agentStatList = jvmGcDetailedBoList .stream() .flatMap(jvmGcDetailedBo -> { - AgentStat newGcCount = new AgentStat(tenantId, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), AgentStatType.JVM_GC_DETAILED.getChartType()); + AgentStat newGcCount = new AgentStat(tenantId, sortKey, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), AgentStatType.JVM_GC_DETAILED.getChartType(), AgentStatField.JVM_GC_DETAILED_GC_NEW_COUNT.getFieldName(), jvmGcDetailedBo.getGcNewCount(), jvmGcDetailedBo.getTimestamp()); - AgentStat newGcTime = new AgentStat(tenantId, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), + AgentStat newGcTime = new AgentStat(tenantId, sortKey, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), AgentStatType.JVM_GC_DETAILED.getChartType(), AgentStatField.JVM_GC_DETAILED_GC_NEW_TIME.getFieldName(), jvmGcDetailedBo.getGcNewTime(), jvmGcDetailedBo.getTimestamp()); - AgentStat codeCacheUsed = new AgentStat(tenantId, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), + AgentStat codeCacheUsed = new AgentStat(tenantId, sortKey, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), AgentStatType.JVM_GC_DETAILED.getChartType(), AgentStatField.JVM_GC_DETAILED_CODE_CACHE_USED.getFieldName(), jvmGcDetailedBo.getCodeCacheUsed(), jvmGcDetailedBo.getTimestamp()); - AgentStat newGenUsed = new AgentStat(tenantId, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), + AgentStat newGenUsed = new AgentStat(tenantId, sortKey, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), AgentStatType.JVM_GC_DETAILED.getChartType(), AgentStatField.JVM_GC_DETAILED_NEW_GEN_USED.getFieldName(), jvmGcDetailedBo.getNewGenUsed(), jvmGcDetailedBo.getTimestamp()); - AgentStat oldGenUsed = new AgentStat(tenantId, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), + AgentStat oldGenUsed = new AgentStat(tenantId, sortKey, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), AgentStatType.JVM_GC_DETAILED.getChartType(), AgentStatField.JVM_GC_DETAILED_OLD_GEN_USED.getFieldName(), jvmGcDetailedBo.getOldGenUsed(), jvmGcDetailedBo.getTimestamp()); - AgentStat survivorSpaceUsed = new AgentStat(tenantId, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), + AgentStat survivorSpaceUsed = new AgentStat(tenantId, sortKey, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), AgentStatType.JVM_GC_DETAILED.getChartType(), AgentStatField.JVM_GC_DETAILED_SURVIVOR_SPACE_USED.getFieldName(), jvmGcDetailedBo.getSurvivorSpaceUsed(), jvmGcDetailedBo.getTimestamp()); - AgentStat permGenUsed = new AgentStat(tenantId, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), + AgentStat permGenUsed = new AgentStat(tenantId, sortKey, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), AgentStatType.JVM_GC_DETAILED.getChartType(), AgentStatField.JVM_GC_DETAILED_PERM_GEN_USED.getFieldName(), jvmGcDetailedBo.getPermGenUsed(), jvmGcDetailedBo.getTimestamp()); - AgentStat metaspaceUsed = new AgentStat(tenantId, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), + AgentStat metaspaceUsed = new AgentStat(tenantId, sortKey, jvmGcDetailedBo.getApplicationName(), jvmGcDetailedBo.getAgentId(), AgentStatType.JVM_GC_DETAILED.getChartType(), AgentStatField.JVM_GC_DETAILED_METASPACE_USED.getFieldName(), jvmGcDetailedBo.getMetaspaceUsed(), jvmGcDetailedBo.getTimestamp()); @@ -166,37 +171,38 @@ public static List convertJvmGCDetailedToAgentStat(List convertTransactionToAgentStat(List transactionBoList, String tenantId) { List agentStatList = transactionBoList.stream() .flatMap(transactionBo -> { - AgentStat collectInterval = new AgentStat(tenantId, transactionBo.getApplicationName(), transactionBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType()); + AgentStat collectInterval = new AgentStat(tenantId, sortKey, transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType(), AgentStatField.TRANSACTION_COLLECT_INTERVAL.getFieldName(), transactionBo.getCollectInterval(), transactionBo.getTimestamp()); - AgentStat sampledNewCount = new AgentStat(tenantId, transactionBo.getApplicationName(), transactionBo.getAgentId(), + AgentStat sampledNewCount = new AgentStat(tenantId, sortKey, transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType(), AgentStatField.TRANSACTION_SAMPLED_NEW_COUNT.getFieldName(), transactionBo.getSampledNewCount(), transactionBo.getTimestamp()); - AgentStat sampledContinuationCount = new AgentStat(tenantId, transactionBo.getApplicationName(), transactionBo.getAgentId(), + AgentStat sampledContinuationCount = new AgentStat(tenantId, sortKey, transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType(), AgentStatField.TRANSACTION_SAMPLED_CONTINUATION_COUNT.getFieldName(), transactionBo.getSampledContinuationCount(), transactionBo.getTimestamp()); - AgentStat unsampledNewCount = new AgentStat(tenantId, transactionBo.getApplicationName(), transactionBo.getAgentId(), + AgentStat unsampledNewCount = new AgentStat(tenantId, sortKey, transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType(), AgentStatField.TRANSACTION_UNSAMPLED_NEW_COUNT.getFieldName(), transactionBo.getUnsampledNewCount(), transactionBo.getTimestamp()); - AgentStat unsampledContinuationCount = new AgentStat(tenantId, transactionBo.getApplicationName(), transactionBo.getAgentId(), + AgentStat unsampledContinuationCount = new AgentStat(tenantId, sortKey, transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType(), AgentStatField.TRANSACTION_UNSAMPLED_CONTINUATION_COUNT.getFieldName(), transactionBo.getUnsampledContinuationCount(), transactionBo.getTimestamp()); - AgentStat skippedNewSkipCount = new AgentStat(tenantId, transactionBo.getApplicationName(), transactionBo.getAgentId(), + AgentStat skippedNewSkipCount = new AgentStat(tenantId, sortKey, transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType(), AgentStatField.TRANSACTION_SKIPPED_NEW_SKIP_COUNT.getFieldName(), transactionBo.getSkippedNewSkipCount(), transactionBo.getTimestamp()); - AgentStat skippedContinuationCount = new AgentStat(tenantId, transactionBo.getApplicationName(), transactionBo.getAgentId(), + AgentStat skippedContinuationCount = new AgentStat(tenantId, sortKey, transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType(), AgentStatField.TRANSACTION_SKIPPED_CONTINUATION_COUNT.getFieldName(), transactionBo.getSkippedContinuationCount(), transactionBo.getTimestamp()); double calculatedTotal = transactionBo.getSampledNewCount() + transactionBo.getSampledContinuationCount() + transactionBo.getUnsampledNewCount() + transactionBo.getUnsampledContinuationCount() + transactionBo.getSkippedNewSkipCount() + transactionBo.getSkippedContinuationCount(); - AgentStat totalCount = new AgentStat(tenantId, transactionBo.getApplicationName(), transactionBo.getAgentId(), + AgentStat totalCount = new AgentStat(tenantId, sortKey, transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType(), AgentStatField.TRANSACTION_TOTAL_COUNT.getFieldName(), calculatedTotal, transactionBo.getTimestamp()); double calculatedTotalCountPerMs = Precision.round(calculatedTotal / (transactionBo.getCollectInterval() / 1000D), 1); - AgentStat totalCountPerMs = new AgentStat(tenantId, transactionBo.getApplicationName(), transactionBo.getAgentId(), + AgentStat totalCountPerMs = new AgentStat(tenantId, sortKey, transactionBo.getApplicationName(), transactionBo.getAgentId(), AgentStatType.TRANSACTION.getChartType(), AgentStatField.TRANSACTION_TOTAL_COUNT_PER_MS.getFieldName(), calculatedTotalCountPerMs, transactionBo.getTimestamp()); @@ -212,11 +218,11 @@ public static List convertTransactionToAgentStat(List public static List convertResponseTimeToAgentStat(List reponseTimeBoList, String tenantId) { List agentStatList = reponseTimeBoList.stream() .flatMap(responseTimeBo -> { - - AgentStat avg = new AgentStat(tenantId, responseTimeBo.getApplicationName(), responseTimeBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(responseTimeBo.getApplicationName(), responseTimeBo.getAgentId(), AgentStatType.RESPONSE_TIME.getChartType()); + AgentStat avg = new AgentStat(tenantId, sortKey, responseTimeBo.getApplicationName(), responseTimeBo.getAgentId(), AgentStatType.RESPONSE_TIME.getChartType(), AgentStatField.RESPONSE_TIME_AVG.getFieldName(), responseTimeBo.getAvg(), responseTimeBo.getTimestamp()); - AgentStat max = new AgentStat(tenantId, responseTimeBo.getApplicationName(), responseTimeBo.getAgentId(), + AgentStat max = new AgentStat(tenantId, sortKey, responseTimeBo.getApplicationName(), responseTimeBo.getAgentId(), AgentStatType.RESPONSE_TIME.getChartType(), AgentStatField.RESPONSE_TIME_MAX.getFieldName(), responseTimeBo.getMax(), responseTimeBo.getTimestamp()); @@ -230,7 +236,8 @@ public static List convertResponseTimeToAgentStat(List convertDeadlockThreadCountToAgentStat(List deadlockThreadCountBoList, String tenantId) { List agentStatList = deadlockThreadCountBoList.stream() .flatMap(deadlockThreadCountBo -> { - AgentStat deadlockedThreadCount = new AgentStat(tenantId, deadlockThreadCountBo.getApplicationName(), deadlockThreadCountBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(deadlockThreadCountBo.getApplicationName(), deadlockThreadCountBo.getAgentId(), AgentStatType.DEADLOCK.getChartType()); + AgentStat deadlockedThreadCount = new AgentStat(tenantId, sortKey, deadlockThreadCountBo.getApplicationName(), deadlockThreadCountBo.getAgentId(), AgentStatType.DEADLOCK.getChartType(), AgentStatField.DEADLOCK_THREAD_COUNT.getFieldName(), deadlockThreadCountBo.getDeadlockedThreadCount(), deadlockThreadCountBo.getTimestamp()); @@ -244,7 +251,8 @@ public static List convertDeadlockThreadCountToAgentStat(List convertFileDescriptorToAgentStat(List fileDescriptorBoList, String tenantId) { List agentStatList = fileDescriptorBoList.stream() .flatMap(fileDescriptorBo -> { - AgentStat openFileDescriptorCount = new AgentStat(tenantId, fileDescriptorBo.getApplicationName(), fileDescriptorBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(fileDescriptorBo.getApplicationName(), fileDescriptorBo.getAgentId(), AgentStatType.FILE_DESCRIPTOR.getChartType()); + AgentStat openFileDescriptorCount = new AgentStat(tenantId, sortKey, fileDescriptorBo.getApplicationName(), fileDescriptorBo.getAgentId(), AgentStatType.FILE_DESCRIPTOR.getChartType(), AgentStatField.OPEN_FILE_DESCRIPTOR_COUNT.getFieldName(), fileDescriptorBo.getOpenFileDescriptorCount(), fileDescriptorBo.getTimestamp()); @@ -258,16 +266,17 @@ public static List convertFileDescriptorToAgentStat(List convertDirectBufferToAgentStat(List directBufferBoList, String tenantId) { List agentStatList = directBufferBoList.stream() .flatMap(directBufferBo -> { - AgentStat directCount = new AgentStat(tenantId, directBufferBo.getApplicationName(), directBufferBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(directBufferBo.getApplicationName(), directBufferBo.getAgentId(), AgentStatType.DIRECT_BUFFER.getChartType()); + AgentStat directCount = new AgentStat(tenantId, sortKey, directBufferBo.getApplicationName(), directBufferBo.getAgentId(), AgentStatType.DIRECT_BUFFER.getChartType(), AgentStatField.DIRECT_BUFFER_DIRECT_COUNT.getFieldName(), directBufferBo.getDirectCount(), directBufferBo.getTimestamp()); - AgentStat directMemoryUsed = new AgentStat(tenantId, directBufferBo.getApplicationName(), directBufferBo.getAgentId(), + AgentStat directMemoryUsed = new AgentStat(tenantId, sortKey, directBufferBo.getApplicationName(), directBufferBo.getAgentId(), AgentStatType.DIRECT_BUFFER.getChartType(), AgentStatField.DIRECT_BUFFER_DIRECT_MEMORY_USED.getFieldName(), directBufferBo.getDirectMemoryUsed(), directBufferBo.getTimestamp()); - AgentStat mappedCount = new AgentStat(tenantId, directBufferBo.getApplicationName(), directBufferBo.getAgentId(), + AgentStat mappedCount = new AgentStat(tenantId, sortKey, directBufferBo.getApplicationName(), directBufferBo.getAgentId(), AgentStatType.DIRECT_BUFFER.getChartType(), AgentStatField.DIRECT_BUFFER_MAPPED_COUNT.getFieldName(), directBufferBo.getMappedCount(), directBufferBo.getTimestamp()); - AgentStat mappedMemoryUsed = new AgentStat(tenantId, directBufferBo.getApplicationName(), directBufferBo.getAgentId(), + AgentStat mappedMemoryUsed = new AgentStat(tenantId, sortKey, directBufferBo.getApplicationName(), directBufferBo.getAgentId(), AgentStatType.DIRECT_BUFFER.getChartType(), AgentStatField.DIRECT_BUFFER_MAPPED_MEMORY_USED.getFieldName(), directBufferBo.getMappedMemoryUsed(), directBufferBo.getTimestamp()); @@ -282,7 +291,8 @@ public static List convertDirectBufferToAgentStat(List convertTotalThreadCountToAgentStat(List totalThreadCountBoList, String tenantId) { List agentStatList = totalThreadCountBoList.stream() .flatMap(totalThreadCountBo -> { - AgentStat totalThreadCount = new AgentStat(tenantId, totalThreadCountBo.getApplicationName(), totalThreadCountBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(totalThreadCountBo.getApplicationName(), totalThreadCountBo.getAgentId(), AgentStatType.TOTAL_THREAD.getChartType()); + AgentStat totalThreadCount = new AgentStat(tenantId, sortKey, totalThreadCountBo.getApplicationName(), totalThreadCountBo.getAgentId(), AgentStatType.TOTAL_THREAD.getChartType(), AgentStatField.TOTAL_THREAD_COUNT.getFieldName(), totalThreadCountBo.getTotalThreadCount(), totalThreadCountBo.getTimestamp()); @@ -298,14 +308,14 @@ public static List convertTotalThreadCountToAgentStat(List convertLoadedClassToAgentStat(List loadedClassBoList, String tenantId) { List agentStatList = loadedClassBoList.stream() .flatMap(loadedClassBo -> { - AgentStat loadedClassCount = new AgentStat(tenantId, loadedClassBo.getApplicationName(), loadedClassBo.getAgentId(), + String sortKey = SortKeyUtils.generateKey(loadedClassBo.getApplicationName(), loadedClassBo.getAgentId(), AgentStatType.LOADED_CLASS.getChartType()); + AgentStat loadedClassCount = new AgentStat(tenantId, sortKey, loadedClassBo.getApplicationName(), loadedClassBo.getAgentId(), AgentStatType.LOADED_CLASS.getChartType(), AgentStatField.CLASS_COUNT_LOAD.getFieldName(), loadedClassBo.getLoadedClassCount(), loadedClassBo.getTimestamp()); - AgentStat unloadedClassCount = new AgentStat(tenantId, loadedClassBo.getApplicationName(), loadedClassBo.getAgentId(), + AgentStat unloadedClassCount = new AgentStat(tenantId, sortKey, loadedClassBo.getApplicationName(), loadedClassBo.getAgentId(), AgentStatType.LOADED_CLASS.getChartType(), AgentStatField.CLASS_COUNT_UN_LOADED.getFieldName(), loadedClassBo.getUnloadedClassCount(), loadedClassBo.getTimestamp()); - return Stream.of(loadedClassCount, unloadedClassCount); } ) @@ -317,7 +327,7 @@ public static List convertLoadedClassToAgentStat(List public static List convertDataSourceToAgentStat(List dataSourceListBoList, String tenantId) { List agentStatList = dataSourceListBoList.stream() .flatMap(dataSourceListBo -> { - + String sortKey = SortKeyUtils.generateKey(dataSourceListBo.getApplicationName(), dataSourceListBo.getAgentId(), AgentStatType.DATASOURCE.getChartType()); Stream.Builder builder = Stream.builder(); for (DataSourceBo dataSourceBo : dataSourceListBo.getList()) { @@ -328,11 +338,11 @@ public static List convertDataSourceToAgentStat(List convertDataSourceToAgentStat(List dataPoint = this.statDao.getSampledAgentStatList(agentId, timeWindow); - for (IN in : dataPoint) { - if (in instanceof SampledJvmGc sampledJvmGc) { - System.out.println("### time: "+ new Date(sampledJvmGc.getGcOldCount().getXVal()) + " sampledJvmGc = " + sampledJvmGc.getGcOldCount().getSumYVal()); - } - } return chartFunction.apply(timeWindow, dataPoint); }