use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.
the class HighSecurityRemoteInstTest method performSetupWork.
private RemoteInstrumentationServiceImpl performSetupWork(boolean highSecurity) {
Map<String, Object> settings = new HashMap<>();
settings.put("app_name", APP_NAME);
if (highSecurity) {
settings.put(AgentConfigImpl.HIGH_SECURITY, Boolean.TRUE);
} else {
settings.put(AgentConfigImpl.HIGH_SECURITY, Boolean.FALSE);
}
manager.setConfigService(new ConfigServiceFactory().createConfigServiceUsingSettings(settings));
TransactionService transactionService = new TransactionService();
manager.setTransactionService(transactionService);
MockCoreService agent = new MockCoreService();
manager.setCoreService(agent);
agent.setInstrumentation(new InstrumentationProxy(new TestInstrumentation(), false));
// Needed by Transaction
TransactionTraceService transactionTraceService = new TransactionTraceService();
manager.setTransactionTraceService(transactionTraceService);
manager.setAttributesService(new AttributesService());
// Needed by Transaction
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
manager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceManager.setRPMService(rpmService);
RemoteInstrumentationServiceImpl impl = new RemoteInstrumentationServiceImpl();
manager.setReinstrumentService(impl);
return impl;
}
use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.
the class DataCollectionConfigCrossAgentTest method createAndVerifyErrorEvent.
private void createAndVerifyErrorEvent(Long expectedCount, Long expectedEndpointCount) {
ErrorServiceImpl errorService = new ErrorServiceImpl(APP_NAME);
rpmService.setErrorService(errorService);
long eventsToCreate = 1;
if (expectedCount > 1) {
eventsToCreate = expectedCount;
}
for (long i = 0; i < eventsToCreate; i++) {
ThrowableError error = ThrowableError.builder(errorService.getErrorCollectorConfig(), APP_NAME, "metric", new Throwable(), System.currentTimeMillis()).build();
errorService.reportError(error);
}
// Verify that the correct number of events were stored in the reservoir
DistributedSamplingPriorityQueue<ErrorEvent> eventQueue = errorService.getReservoir(APP_NAME);
assertNotNull(eventQueue);
assertEquals(expectedCount.intValue(), eventQueue.size());
// Verify that we sent (or didn't send) the appropriate events
errorService.harvestEvents(APP_NAME);
int errorEventsSeen = rpmService.getErrorEventsSeen();
assertEquals(expectedEndpointCount.intValue(), errorEventsSeen);
}
use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.
the class DataCollectionConfigCrossAgentTest method createAndVerifyErrorTrace.
private void createAndVerifyErrorTrace(Long expectedCount, Long expectedEndpointCount) {
ErrorServiceImpl errorService = new ErrorServiceImpl(APP_NAME);
rpmService.setErrorService(errorService);
long eventsToCreate = 1;
if (expectedCount > 1) {
eventsToCreate = expectedCount;
}
for (long i = 0; i < eventsToCreate; i++) {
ThrowableError error = ThrowableError.builder(errorService.getErrorCollectorConfig(), APP_NAME, "metric", new Throwable(), System.currentTimeMillis()).build();
errorService.reportError(error);
}
// Verify that the correct number of traces were stored in the reservoir
assertEquals(expectedCount.intValue(), errorService.getTracedErrorsCount());
// Verify that we sent (or didn't send) the appropriate traces
errorService.harvestTracedErrors(APP_NAME, new StatsEngineImpl());
int errorTracesSeen = rpmService.getErrorTracesSeen();
assertEquals(expectedEndpointCount.intValue(), errorTracesSeen);
}
use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.
the class MockRPMServiceManager method createRPMService.
private IRPMService createRPMService(String appName) {
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(appName);
rpmService.setEverConnected(true);
rpmService.setIsConnected(true);
ErrorService errorService = new ErrorServiceImpl(appName);
errorService.addHarvestableToService();
try {
errorService.start();
} catch (Exception e) {
}
rpmService.setErrorService(errorService);
addHarvestablesToServices(appName);
return rpmService;
}
use of com.newrelic.agent.errors.ErrorServiceImpl 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;
}
Aggregations