Search in sources :

Example 96 with MockRPMService

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

the class SyntheticsTransactionSamplerTest method createServiceManager.

private static void createServiceManager(Map<String, Object> configMap) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
    serviceManager.setConfigService(configService);
    DatabaseService dbService = new DatabaseService();
    serviceManager.setDatabaseService(dbService);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmService.setIsConnected(true);
    rpmServiceManager.setRPMService(rpmService);
    CommandParser commandParser = new CommandParser();
    serviceManager.setCommandParser(commandParser);
    AttributesService attService = new AttributesService();
    serviceManager.setAttributesService(attService);
    TransactionTraceService ttService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(ttService);
    ttService.start();
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) DatabaseService(com.newrelic.agent.database.DatabaseService) MockRPMService(com.newrelic.agent.MockRPMService) CommandParser(com.newrelic.agent.commands.CommandParser)

Example 97 with MockRPMService

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

the class TransactionTraceServiceTest method appName.

@Test
public void appName() throws Exception {
    Map<String, Object> configMap = createConfigMap();
    Map<String, Object> ttConfigMap = new HashMap<>();
    configMap.put(AgentConfigImpl.ENABLE_AUTO_APP_NAMING, true);
    configMap.put("transaction_tracer", ttConfigMap);
    ttConfigMap.put(TransactionTracerConfigImpl.ENABLED, true);
    ttConfigMap.put(TransactionTracerConfigImpl.COLLECT_TRACES, true);
    ttConfigMap.put(TransactionTracerConfigImpl.TRANSACTION_THRESHOLD, 0L);
    createServiceManager(configMap);
    rpmServiceManager.getOrCreateRPMService("App Name 1");
    rpmServiceManager.getOrCreateRPMService("App Name 2");
    TransactionTraceService ttService = ServiceFactory.getTransactionTraceService();
    TransactionData td = createTransactionData("/en/betting/Football/*", "App Name 1", 100L);
    ttService.dispatcherTransactionFinished(td, null);
    td = createTransactionData("/ru/betting/Motorsport/*", "App Name 2", 200L);
    ttService.dispatcherTransactionFinished(td, null);
    ttService.afterHarvest("App Name 1");
    MockRPMService rpmService = (MockRPMService) ServiceFactory.getRPMServiceManager().getRPMService("App Name 1");
    Assert.assertEquals(1, rpmService.getTraces().size());
    Assert.assertEquals("/en/betting/Football/*", rpmService.getTraces().get(0).getRequestUri());
    Assert.assertEquals(100L, rpmService.getTraces().get(0).getDuration());
    ttService.afterHarvest("App Name 2");
    rpmService = (MockRPMService) ServiceFactory.getRPMServiceManager().getRPMService("App Name 2");
    Assert.assertEquals(1, rpmService.getTraces().size());
    Assert.assertEquals("/ru/betting/Motorsport/*", rpmService.getTraces().get(0).getRequestUri());
    Assert.assertEquals(200L, rpmService.getTraces().get(0).getDuration());
}
Also used : HashMap(java.util.HashMap) TransactionData(com.newrelic.agent.TransactionData) MockRPMService(com.newrelic.agent.MockRPMService) Test(org.junit.Test)

Aggregations

MockRPMService (com.newrelic.agent.MockRPMService)97 Test (org.junit.Test)59 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)44 MockServiceManager (com.newrelic.agent.MockServiceManager)39 MockHarvestService (com.newrelic.agent.MockHarvestService)30 HashMap (java.util.HashMap)28 TransactionService (com.newrelic.agent.TransactionService)26 ConfigService (com.newrelic.agent.config.ConfigService)21 MockCoreService (com.newrelic.agent.MockCoreService)20 StatsEngineImpl (com.newrelic.agent.stats.StatsEngineImpl)18 HarvestService (com.newrelic.agent.HarvestService)17 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)17 ThreadService (com.newrelic.agent.ThreadService)15 StatsService (com.newrelic.agent.stats.StatsService)15 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)15 OtherRootSqlTracer (com.newrelic.agent.tracers.OtherRootSqlTracer)15 SqlTracer (com.newrelic.agent.tracers.SqlTracer)15 Tracer (com.newrelic.agent.tracers.Tracer)15 BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)15 TransactionData (com.newrelic.agent.TransactionData)14