use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class ErrorServiceTest method attributesDisabledWithIntrinsics.
@SuppressWarnings("unchecked")
@Test
public void attributesDisabledWithIntrinsics() throws Exception {
Map<String, Object> config = createConfig("java.lang.Exception");
setConfigAttributes(config, false, true);
EventTestHelper.createServiceManager(config);
ErrorServiceImpl errorService = (ErrorServiceImpl) ServiceFactory.getRPMService().getErrorService();
MockRPMService rpmService = (MockRPMService) ServiceFactory.getRPMService();
rpmService.setIsConnected(true);
TransactionService txService = ServiceFactory.getTransactionService();
Throwable error = new ArrayIndexOutOfBoundsException();
Map<String, String> requestParams = new HashMap<>();
requestParams.put("key1", "value1");
Map<String, Object> agentParams = new HashMap<>();
agentParams.put("key2", 2L);
Map<String, Object> userParams = new HashMap<>();
userParams.put("key3", "value3");
Map<String, Object> errorParams = new HashMap<>();
errorParams.put("key4", "value4");
Map<String, Object> intrinsics = new HashMap<>();
intrinsics.put("key5", "value5");
TransactionData data = createTransactionData(true, 0, error, false, requestParams, userParams, agentParams, errorParams, intrinsics);
TransactionStats transactionStats = new TransactionStats();
txService.transactionFinished(data, transactionStats);
List<TracedError> actualErrors = errorService.getAndClearTracedErrors(APP_NAME, new StatsEngineImpl());
Assert.assertEquals(1, actualErrors.size());
JSONArray serializedError = (JSONArray) AgentHelper.serializeJSON(actualErrors.get(0));
Assert.assertNotNull(serializedError);
Map<String, Object> params = (Map<String, Object>) serializedError.get(4);
Assert.assertEquals(2, params.size());
Assert.assertNotNull(params.get("stack_trace"));
Assert.assertNotNull(params.get("intrinsics"));
Map<String, Object> actual = (Map<String, Object>) params.get("intrinsics");
Assert.assertEquals(6, actual.size());
Assert.assertEquals("value5", actual.get("key5"));
Assert.assertEquals(false, actual.get("error.expected"));
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class DatabaseServiceTest method createServiceManager.
private MockServiceManager createServiceManager(Map<String, Object> configMap) throws Exception {
AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
serviceManager.setConfigService(configService);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
DatabaseService dbService = new DatabaseService();
serviceManager.setDatabaseService(dbService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setEverConnected(true);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceManager.setRPMService(rpmService);
configService.start();
serviceManager.start();
sqlTraceService.start();
return serviceManager;
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class WebRequestDispatcherTest method createServiceManager.
private static void createServiceManager(AgentConfig config, Map<String, Object> configMap) throws Exception {
ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
MockServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
serviceManager.setConfigService(configService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
AttributesService attributesService = new AttributesService();
serviceManager.setAttributesService(attributesService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceManager.setRPMService(rpmService);
configService.start();
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class GeneratorVisitTracerFactoryTest method createServiceManager.
private static void createServiceManager(Map<String, Object> map) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
serviceManager.setConfigService(configService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceManager.setRPMService(rpmService);
configService.start();
serviceManager.setNormalizationService(new NormalizationServiceImpl());
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
statsService.start();
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class RumParserTest method createServiceManager.
private static void createServiceManager(Map<String, Object> map) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
serviceManager.setConfigService(configService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceManager.setRPMService(rpmService);
configService.start();
serviceManager.setNormalizationService(new NormalizationServiceImpl());
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
statsService.start();
}
Aggregations