use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.
the class AgentTestUtils method createServiceManager.
public static 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("name");
rpmService.setEverConnected(true);
rpmService.setErrorService(new ErrorServiceImpl("name"));
rpmServiceManager.setRPMService(rpmService);
configService.start();
serviceManager.start();
sqlTraceService.start();
return serviceManager;
}
use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.
the class SpanIdOnErrorsTest method matchFirstErrorToOriginatingSpan.
private void matchFirstErrorToOriginatingSpan(String expectedSpanName) {
ErrorServiceImpl errorService = (ErrorServiceImpl) ServiceFactory.getRPMService().getErrorService();
final DistributedSamplingPriorityQueue<ErrorEvent> reservoir = errorService.getReservoir(ServiceFactory.getRPMService().getApplicationName());
assertTrue(reservoir.size() > 0);
final ErrorEvent errorEvent = reservoir.asList().get(0);
assertTrue(errorEvent.getAgentAttributes().containsKey("spanId"));
assertMethodWhereErrorOriginatedHasThisSpanId(errorEvent.getAgentAttributes().get("spanId"), expectedSpanName);
}
use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.
the class SpanIdOnErrorsTest method noTransactionErrorIfErrorIsHandled.
@Test
public void noTransactionErrorIfErrorIsHandled() {
runTransaction(new SpanErrorFlow.ThrowHandledException());
ErrorServiceImpl errorService = (ErrorServiceImpl) ServiceFactory.getRPMService().getErrorService();
final DistributedSamplingPriorityQueue<ErrorEvent> reservoir = errorService.getReservoir(ServiceFactory.getRPMService().getApplicationName());
assertEquals(0, reservoir.size());
}
use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.
the class SpanParentTest method testErrorAttributes.
@Test
public void testErrorAttributes() throws Exception {
EnvironmentHolder holder = setupEnvironemntHolder("all_enabled_test");
Header actualHeader = txnStarter(true);
try {
TransactionDataList transactionList = holder.getTransactionList();
ServiceFactory.getHarvestService().harvestNow();
assertEquals(1, transactionList.size());
Collection<Tracer> tracers = transactionList.get(0).getTracers();
Tracer tracer = ((TracerList) tracers).get(0);
String expectedGuid = tracer.getGuid();
String actualGuid = findGuid(actualHeader.getValue());
Assert.assertEquals(expectedGuid, actualGuid);
ErrorServiceImpl errorService = (ErrorServiceImpl) ServiceFactory.getRPMService().getErrorService();
List<TracedError> tracedErrors = errorService.getAndClearTracedErrors();
assertEquals(1, tracedErrors.size());
TracedError errorTrace = tracedErrors.get(0);
Map<String, ?> errorAtts = errorTrace.getIntrinsicAtts();
Assert.assertNotNull(errorAtts.get("traceId"));
Assert.assertNotNull(errorAtts.get("guid"));
Assert.assertNotNull(errorAtts.get("priority"));
Assert.assertNotNull(errorAtts.get("sampled"));
} finally {
holder.close();
}
}
use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest 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);
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(map);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, 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