use of com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch in project pinpoint by naver.
the class GrpcStatMessageConverter method toMessage.
@Override
public GeneratedMessageV3 toMessage(MetricType message) {
if (message instanceof AgentStatMetricSnapshotBatch) {
final AgentStatMetricSnapshotBatch agentStatMetricSnapshotBatch = (AgentStatMetricSnapshotBatch) message;
final PAgentStatBatch.Builder agentStatBatchBuilder = PAgentStatBatch.newBuilder();
// Skip agentId, startTimestamp
for (AgentStatMetricSnapshot agentStatMetricSnapshot : agentStatMetricSnapshotBatch.getAgentStats()) {
final PAgentStat agentStat = converAgentStat(agentStatMetricSnapshot);
agentStatBatchBuilder.addAgentStat(agentStat);
}
return agentStatBatchBuilder.build();
} else if (message instanceof AgentStatMetricSnapshot) {
final AgentStatMetricSnapshot agentStatMetricSnapshot = (AgentStatMetricSnapshot) message;
final PAgentStat agentStat = converAgentStat(agentStatMetricSnapshot);
return agentStat;
} else if (message instanceof AgentCustomMetricSnapshotBatch) {
final AgentCustomMetricSnapshotBatch agentCustomMetricSnapshotBatch = (AgentCustomMetricSnapshotBatch) message;
final PCustomMetricMessage pCustomMetricMessage = customMetricMessageConverter.toMessage(agentCustomMetricSnapshotBatch);
return pCustomMetricMessage;
} else if (message instanceof AgentUriStatData) {
final AgentUriStatData agentUriStatData = (AgentUriStatData) message;
final PAgentUriStat agentUriStat = uriStatMessageConverter.toMessage(agentUriStatData);
return agentUriStat;
}
return null;
}
use of com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch in project pinpoint by naver.
the class AgentStatMonitorTest method testAgentStatMonitor.
@Test
public void testAgentStatMonitor() throws InterruptedException {
// Given
final long collectionIntervalMs = 1000 * 1;
final int numCollectionsPerBatch = 2;
final int minNumBatchToTest = 2;
final long totalTestDurationMs = collectionIntervalMs + collectionIntervalMs * numCollectionsPerBatch * minNumBatchToTest;
// profilerConfig.getProfileJvmStatCollectIntervalMs(), profilerConfig.getProfileJvmStatBatchSendCount()
MonitorConfig mockProfilerConfig = Mockito.mock(MonitorConfig.class);
Mockito.when(mockProfilerConfig.getProfileJvmStatCollectIntervalMs()).thenReturn((int) collectionIntervalMs);
Mockito.when(mockProfilerConfig.getProfileJvmStatBatchSendCount()).thenReturn(numCollectionsPerBatch);
// When
AgentStatMonitor monitor = new DefaultAgentStatMonitor(this.dataSender, "agentId", System.currentTimeMillis(), agentStatCollector, null, null, mockProfilerConfig);
monitor.start();
Thread.sleep(totalTestDurationMs);
monitor.stop();
// Then
assertTrue(tBaseRecorder.size() >= minNumBatchToTest);
for (AgentStatMetricSnapshotBatch agentStatBatch : tBaseRecorder) {
logger.debug("agentStatBatch:{}", agentStatBatch);
assertTrue(agentStatBatch.getAgentStats().size() <= numCollectionsPerBatch);
}
}
use of com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch in project pinpoint by naver.
the class CollectJob method sendAgentStats.
private void sendAgentStats() {
// prepare TAgentStat object.
// TODO multi thread issue.
// If we reuse TAgentStat, there could be concurrency issue because data sender runs in a different thread.
final AgentStatMetricSnapshotBatch agentStatBatch = new AgentStatMetricSnapshotBatch();
agentStatBatch.setAgentId(agentId);
agentStatBatch.setStartTimestamp(agentStartTimestamp);
agentStatBatch.setAgentStats(this.agentStats);
// If we reuse agentStats list, there could be concurrency issue because data sender runs in a different
// thread.
// So create new list.
this.agentStats = new ArrayList<>(numCollectionsPerBatch);
logger.trace("collect agentStat:{}", agentStatBatch);
dataSender.send(agentStatBatch);
}
use of com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch in project pinpoint by naver.
the class StatThriftMessageConverter method toMessage.
@Override
public TBase<?, ?> toMessage(MetricType message) {
if (message instanceof AgentStatMetricSnapshotBatch) {
final AgentStatMetricSnapshotBatch agentStatMetricSnapshotBatch = (AgentStatMetricSnapshotBatch) message;
final TAgentStatBatch agentStatBatch = new TAgentStatBatch();
agentStatBatch.setAgentId(agentStatMetricSnapshotBatch.getAgentId());
agentStatBatch.setStartTimestamp(agentStatMetricSnapshotBatch.getStartTimestamp());
for (AgentStatMetricSnapshot agentStatMetricSnapshot : agentStatMetricSnapshotBatch.getAgentStats()) {
final TAgentStat agentStat = convertAgentStat(agentStatMetricSnapshot);
agentStatBatch.addToAgentStats(agentStat);
}
return agentStatBatch;
} else if (message instanceof AgentStatMetricSnapshot) {
final AgentStatMetricSnapshot agentStatMetricSnapshot = (AgentStatMetricSnapshot) message;
final TAgentStat agentStat = convertAgentStat(agentStatMetricSnapshot);
return agentStat;
}
return null;
}
Aggregations