Search in sources :

Example 1 with AgentStatMetricSnapshotBatch

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;
}
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 AgentStatMetricSnapshotBatch

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);
    }
}
Also used : DefaultAgentStatMonitor(com.navercorp.pinpoint.profiler.monitor.DefaultAgentStatMonitor) DefaultAgentStatMonitor(com.navercorp.pinpoint.profiler.monitor.DefaultAgentStatMonitor) AgentStatMonitor(com.navercorp.pinpoint.profiler.monitor.AgentStatMonitor) AgentStatMetricSnapshotBatch(com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch) MonitorConfig(com.navercorp.pinpoint.profiler.context.monitor.config.MonitorConfig) Test(org.junit.Test)

Example 3 with AgentStatMetricSnapshotBatch

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

Example 4 with AgentStatMetricSnapshotBatch

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

Aggregations

AgentStatMetricSnapshotBatch (com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch)4 AgentStatMetricSnapshot (com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshot)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 MonitorConfig (com.navercorp.pinpoint.profiler.context.monitor.config.MonitorConfig)1 AgentStatMonitor (com.navercorp.pinpoint.profiler.monitor.AgentStatMonitor)1 DefaultAgentStatMonitor (com.navercorp.pinpoint.profiler.monitor.DefaultAgentStatMonitor)1 AgentCustomMetricSnapshotBatch (com.navercorp.pinpoint.profiler.monitor.metric.AgentCustomMetricSnapshotBatch)1 AgentUriStatData (com.navercorp.pinpoint.profiler.monitor.metric.uri.AgentUriStatData)1 TAgentStat (com.navercorp.pinpoint.thrift.dto.TAgentStat)1 TAgentStatBatch (com.navercorp.pinpoint.thrift.dto.TAgentStatBatch)1 Test (org.junit.Test)1