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();
}
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());
}
Aggregations