Search in sources :

Example 6 with HarvestServiceImpl

use of com.newrelic.agent.HarvestServiceImpl in project newrelic-java-agent by newrelic.

the class TransactionEventsServiceTest method testTransactionEventFasterHarvest.

@Test
public void testTransactionEventFasterHarvest() throws Exception {
    Map<String, Object> config = new HashMap<>();
    config.put(AgentConfigImpl.APP_NAME, APP_NAME);
    EventTestHelper.setAppName(APP_NAME);
    EventTestHelper.createServiceManager(config);
    service = new TransactionEventsService(mock(TransactionDataToDistributedTraceIntrinsics.class));
    ((MockServiceManager) ServiceFactory.getServiceManager()).setTransactionEventsService(service);
    environmentService = new EnvironmentServiceImpl();
    ((MockServiceManager) ServiceFactory.getServiceManager()).setEnvironmentService(environmentService);
    ServiceManager serviceManager = spy(ServiceFactory.getServiceManager());
    ServiceFactory.setServiceManager(serviceManager);
    HarvestServiceImpl harvestService = spy(new HarvestServiceImpl());
    doReturn(harvestService).when(serviceManager).getHarvestService();
    doReturn(0L).when(harvestService).getInitialDelay();
    service.addHarvestableToService(APP_NAME);
    service.configureHarvestables(60, 3);
    assertEquals(3, service.getMaxSamplesStored());
    service.doStart();
    Map<String, Object> connectionInfo = new HashMap<>();
    Map<String, Object> eventHarvest = new HashMap<>();
    Map<String, Object> harvestLimits = new HashMap<>();
    // 5 is the lowest allowable value
    eventHarvest.put("report_period_ms", 5000L);
    eventHarvest.put("harvest_limits", harvestLimits);
    harvestLimits.put("analytic_event_data", 100L);
    connectionInfo.put("event_harvest_config", eventHarvest);
    harvestService.startHarvestables(ServiceFactory.getRPMService(), AgentConfigImpl.createAgentConfig(connectionInfo));
    getEventData(APP_NAME);
    Thread.sleep(500);
    DistributedSamplingPriorityQueue<TransactionEvent> currentEventData = createAndSendTransaction();
    assertEquals(1, currentEventData.size());
    Thread.sleep(6000);
    checkForEvent();
    assertEquals(1, currentEventData.size());
    createAndSendTransaction();
    Thread.sleep(6000);
    checkForEvent();
}
Also used : HashMap(java.util.HashMap) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) HarvestServiceImpl(com.newrelic.agent.HarvestServiceImpl) Test(org.junit.Test)

Example 7 with HarvestServiceImpl

use of com.newrelic.agent.HarvestServiceImpl in project newrelic-java-agent by newrelic.

the class DistributedTraceServiceImplTest method before.

@Before
public void before() throws Exception {
    Map<String, Object> config = new HashMap<>();
    config.put(AgentConfigImpl.APP_NAME, "Test");
    Map<String, Object> dtConfig = new HashMap<>();
    dtConfig.put("enabled", true);
    config.put("distributed_tracing", dtConfig);
    Map<String, Object> spanConfig = new HashMap<>();
    spanConfig.put("collect_span_events", true);
    config.put("span_events", spanConfig);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(config), Collections.<String, Object>emptyMap());
    serviceManager = new MockServiceManager(configService);
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.setConfigService(configService);
    serviceManager.setTransactionTraceService(new TransactionTraceService());
    serviceManager.setTransactionService(new TransactionService());
    distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    serviceManager.setHarvestService(new HarvestServiceImpl());
    serviceManager.setStatsService(new StatsServiceImpl());
    rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    ServiceFactory.getServiceManager().start();
}
Also used : TransactionService(com.newrelic.agent.TransactionService) HashMap(java.util.HashMap) HarvestServiceImpl(com.newrelic.agent.HarvestServiceImpl) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) Before(org.junit.Before)

Aggregations

HarvestServiceImpl (com.newrelic.agent.HarvestServiceImpl)7 MockServiceManager (com.newrelic.agent.MockServiceManager)6 TransactionService (com.newrelic.agent.TransactionService)4 EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)4 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)4 HashMap (java.util.HashMap)4 ThreadService (com.newrelic.agent.ThreadService)3 ConfigService (com.newrelic.agent.config.ConfigService)3 ProfilerService (com.newrelic.agent.profile.ProfilerService)3 RPMConnectionServiceImpl (com.newrelic.agent.rpm.RPMConnectionServiceImpl)3 ServiceManager (com.newrelic.agent.service.ServiceManager)3 Test (org.junit.Test)3 HarvestService (com.newrelic.agent.HarvestService)2 MockRPMService (com.newrelic.agent.MockRPMService)2 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)2 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)2 RPMConnectionService (com.newrelic.agent.rpm.RPMConnectionService)2 InfiniteTracing (com.newrelic.InfiniteTracing)1 AgentConnectionEstablishedListener (com.newrelic.agent.AgentConnectionEstablishedListener)1 ExpirationService (com.newrelic.agent.ExpirationService)1