Search in sources :

Example 1 with AgentStatMonitor

use of com.navercorp.pinpoint.profiler.monitor.AgentStatMonitor 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)

Aggregations

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 AgentStatMetricSnapshotBatch (com.navercorp.pinpoint.profiler.monitor.metric.AgentStatMetricSnapshotBatch)1 Test (org.junit.Test)1