Search in sources :

Example 21 with ErrorServiceImpl

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;
}
Also used : RemoteInstrumentationServiceImpl(com.newrelic.agent.reinstrument.RemoteInstrumentationServiceImpl) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) HashMap(java.util.HashMap) AttributesService(com.newrelic.agent.attributes.AttributesService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) ConfigServiceFactory(com.newrelic.agent.config.ConfigServiceFactory)

Example 22 with ErrorServiceImpl

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);
}
Also used : ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) ErrorEvent(com.newrelic.agent.model.ErrorEvent) ThrowableError(com.newrelic.agent.errors.ThrowableError)

Example 23 with ErrorServiceImpl

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);
}
Also used : ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsEngineImpl(com.newrelic.agent.stats.StatsEngineImpl) ThrowableError(com.newrelic.agent.errors.ThrowableError)

Example 24 with ErrorServiceImpl

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;
}
Also used : ErrorService(com.newrelic.agent.errors.ErrorService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl)

Example 25 with ErrorServiceImpl

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;
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) AgentConfig(com.newrelic.agent.config.AgentConfig) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) MockConfigService(com.newrelic.agent.MockConfigService) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockHarvestService(com.newrelic.agent.MockHarvestService) MockCoreService(com.newrelic.agent.MockCoreService) MockRPMService(com.newrelic.agent.MockRPMService)

Aggregations

ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)34 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)22 TransactionService (com.newrelic.agent.TransactionService)19 MockRPMService (com.newrelic.agent.MockRPMService)17 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)17 ConfigService (com.newrelic.agent.config.ConfigService)17 MockServiceManager (com.newrelic.agent.MockServiceManager)16 StatsService (com.newrelic.agent.stats.StatsService)16 MockCoreService (com.newrelic.agent.MockCoreService)13 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)13 MockHarvestService (com.newrelic.agent.MockHarvestService)12 ThreadService (com.newrelic.agent.ThreadService)12 HarvestService (com.newrelic.agent.HarvestService)11 AttributesService (com.newrelic.agent.attributes.AttributesService)11 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)9 AgentConfig (com.newrelic.agent.config.AgentConfig)8 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)8 HashMap (java.util.HashMap)8 NormalizationServiceImpl (com.newrelic.agent.normalization.NormalizationServiceImpl)7 Test (org.junit.Test)7