Search in sources :

Example 1 with AgentStatMetricSnapshot

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;
}
Also used : AgentStatMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot) PAgentStatBatch(com.navercorp.pinpoint.grpc.trace.PAgentStatBatch) AgentUriStatData(com.navercorp.pinpoint.profiler.monitor.metric.uri.AgentUriStatData) PAgentStat(com.navercorp.pinpoint.grpc.trace.PAgentStat) PCustomMetricMessage(com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage) PAgentUriStat(com.navercorp.pinpoint.grpc.trace.PAgentUriStat) AgentStatMetricSnapshotBatch(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch) AgentCustomMetricSnapshotBatch(com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshotBatch)

Example 2 with AgentStatMetricSnapshot

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;
    }
}
Also used : AgentStatMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot)

Example 3 with AgentStatMetricSnapshot

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));
}
Also used : AgentStatMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot) MetricType(com.navercorp.pinpoint.profiler.monitor.metric.MetricType) AgentStatMetricSnapshotBatch(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch) Test(org.junit.Test)

Example 4 with AgentStatMetricSnapshot

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;
}
Also used : AgentStatMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot) TBaseRecorderAdaptor(com.navercorp.pinpoint.test.TBaseRecorderAdaptor) MetricType(com.navercorp.pinpoint.profiler.monitor.metric.MetricType) ListenableDataSender(com.navercorp.pinpoint.test.ListenableDataSender) Before(org.junit.Before)

Example 5 with AgentStatMetricSnapshot

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;
}
Also used : AgentStatMetricSnapshot(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot)

Aggregations

AgentStatMetricSnapshot (com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot)6 AgentStatMetricSnapshotBatch (com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch)3 MetricType (com.navercorp.pinpoint.profiler.monitor.metric.MetricType)2 PAgentStat (com.navercorp.pinpoint.grpc.trace.PAgentStat)1 PAgentStatBatch (com.navercorp.pinpoint.grpc.trace.PAgentStatBatch)1 PAgentUriStat (com.navercorp.pinpoint.grpc.trace.PAgentUriStat)1 PCustomMetricMessage (com.navercorp.pinpoint.grpc.trace.PCustomMetricMessage)1 AgentCustomMetricSnapshotBatch (com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshotBatch)1 AgentUriStatData (com.navercorp.pinpoint.profiler.monitor.metric.uri.AgentUriStatData)1 ListenableDataSender (com.navercorp.pinpoint.test.ListenableDataSender)1 TBaseRecorderAdaptor (com.navercorp.pinpoint.test.TBaseRecorderAdaptor)1 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)1 TAgentStatBatch (com.navercorp.pinpoint.thrift.dto.TAgentStatBatch)1 Before (org.junit.Before)1 Test (org.junit.Test)1