Search in sources :

Example 11 with ErrorServiceImpl

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;
}
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) DatabaseService(com.newrelic.agent.database.DatabaseService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) AgentConfig(com.newrelic.agent.config.AgentConfig) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) 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)

Example 12 with ErrorServiceImpl

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

Example 13 with ErrorServiceImpl

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

Example 14 with ErrorServiceImpl

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();
    }
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) Header(org.apache.http.Header) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) TracedError(com.newrelic.agent.errors.TracedError) EnvironmentHolder(test.newrelic.test.agent.EnvironmentHolder) Tracer(com.newrelic.agent.tracers.Tracer) TracerList(com.newrelic.agent.TracerList) Test(org.junit.Test)

Example 15 with ErrorServiceImpl

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();
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) AgentConfig(com.newrelic.agent.config.AgentConfig) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) NormalizationServiceImpl(com.newrelic.agent.normalization.NormalizationServiceImpl)

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