use of com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot 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.AgentStatMetricSnapshot in project pinpoint by naver.
the class CollectJob method run.
@Override
public void run() {
final long currentCollectionTimestamp = System.currentTimeMillis();
final long collectInterval = currentCollectionTimestamp - this.prevCollectionTimestamp;
try {
final AgentStatMetricSnapshot agentStat = agentStatCollector.collect();
agentStat.setTimestamp(currentCollectionTimestamp);
agentStat.setCollectInterval(collectInterval);
this.agentStats.add(agentStat);
if (++this.collectCount >= numCollectionsPerBatch) {
sendAgentStats();
this.collectCount = 0;
}
} catch (Exception ex) {
logger.warn("AgentStat collect failed. Caused:{}", ex.getMessage(), ex);
} finally {
this.prevCollectionTimestamp = currentCollectionTimestamp;
}
}
use of com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot in project pinpoint by naver.
the class CollectJobTest method run.
@Test
public void run() throws Exception {
AgentStatMetricCollector<AgentStatMetricSnapshot> agentStatMetricCollector = mockAgentStatMetricCollector();
Mockito.when(agentStatMetricCollector.collect()).thenReturn(new AgentStatMetricSnapshot());
DataSender<MetricType> dataSender = mock(DataSender.class);
CollectJob job = new CollectJob(dataSender, "agent", 0, agentStatMetricCollector, 1);
job.run();
Mockito.verify(dataSender).send(any(AgentStatMetricSnapshotBatch.class));
}
use of com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot in project pinpoint by naver.
the class AgentStatMonitorTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(agentStatCollector.collect()).thenReturn(new AgentStatMetricSnapshot());
this.tBaseRecorder = new TBaseRecorder<>();
ListenableDataSender.Listener<? extends MetricType> recorderAdaptor = new TBaseRecorderAdaptor<>(tBaseRecorder);
ListenableDataSender<MetricType> listenableDataSender = new ListenableDataSender<>("testDataSender");
listenableDataSender.setListener((ListenableDataSender.Listener<MetricType>) recorderAdaptor);
this.dataSender = listenableDataSender;
}
use of com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot in project pinpoint by naver.
the class AgentStatCollector method collect.
@Override
public AgentStatMetricSnapshot collect() {
AgentStatMetricSnapshot agentStat = new AgentStatMetricSnapshot();
agentStat.setAgentId(agentId);
agentStat.setStartTimestamp(agentStartTimestamp);
agentStat.setGc(jvmGcMetricCollector.collect());
agentStat.setCpuLoad(cpuLoadMetricCollector.collect());
agentStat.setTransaction(transactionMetricCollector.collect());
agentStat.setActiveTrace(activeTraceMetricCollector.collect());
agentStat.setDataSourceList(dataSourceMetricCollector.collect());
agentStat.setResponseTime(responseTimeMetricCollector.collect());
agentStat.setDeadlock(deadlockMetricCollector.collect());
agentStat.setFileDescriptor(fileDescriptorMetricCollector.collect());
agentStat.setDirectBuffer(bufferMetricCollector.collect());
agentStat.setTotalThread(totalThreadMetricCollector.collect());
agentStat.setLoadedClassCount(loadedClassMetricCollector.collect());
return agentStat;
}
Aggregations