Search in sources :

Example 26 with ErrorServiceImpl

use of com.newrelic.agent.errors.ErrorServiceImpl 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();
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) MockCoreService(com.newrelic.agent.MockCoreService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) MockRPMService(com.newrelic.agent.MockRPMService)

Example 27 with ErrorServiceImpl

use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.

the class DefaultTracerTest method testTransactionABParenting.

/**
 * Transaction A has spans 1, 2, and 3. Span 2 is active when a distributed tracing payload is created.
 * Transaction B has spans 5 and 6. The payload from span 2 is accepted when span 5 is active.
 *
 * Verify that all the parenting attributes are correct.
 */
@Test
public void testTransactionABParenting() {
    DistributedTraceServiceImpl dts = (DistributedTraceServiceImpl) ServiceFactory.getServiceManager().getDistributedTraceService();
    Map<String, Object> configMap = ImmutableMap.<String, Object>builder().put("distributed_tracing", ImmutableMap.builder().put("account_id", "12345").put("trusted_account_key", "67890").put("primary_application_id", "789").build()).build();
    dts.connected(null, AgentConfigFactory.createAgentConfig(configMap, null, null));
    TransactionActivity.clear();
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    DefaultTracer span1Tracer = new OtherRootTracer(tx, new ClassMethodSignature("class", "span1", "()V"), null, DefaultTracer.NULL_METRIC_NAME_FORMATTER);
    tx.getTransactionActivity().tracerStarted(span1Tracer);
    tx.setTransactionName(com.newrelic.api.agent.TransactionNamePriority.CUSTOM_HIGH, true, "Transaction A");
    DefaultTracer span2Tracer = new OtherRootTracer(tx, new ClassMethodSignature("class", "span2", "()V"), null, DefaultTracer.NULL_METRIC_NAME_FORMATTER);
    tx.getTransactionActivity().tracerStarted(span2Tracer);
    DistributedTracePayload payload = new BoundTransactionApiImpl(span2Tracer.getTransaction()).createDistributedTracePayload();
    DefaultTracer span3Tracer = new OtherRootTracer(tx, new ClassMethodSignature("class", "span3", "()V"), null, DefaultTracer.NULL_METRIC_NAME_FORMATTER);
    tx.getTransactionActivity().tracerStarted(span3Tracer);
    span3Tracer.finish(Opcodes.ARETURN, null);
    span2Tracer.finish(Opcodes.ARETURN, null);
    span1Tracer.finish(Opcodes.ARETURN, null);
    TransactionActivity.clear();
    Transaction.clearTransaction();
    Transaction txB = Transaction.getTransaction();
    DefaultTracer span5Tracer = new OtherRootTracer(txB, new ClassMethodSignature("class", "span5", "()V"), null, DefaultTracer.NULL_METRIC_NAME_FORMATTER);
    txB.getTransactionActivity().tracerStarted(span5Tracer);
    span5Tracer.getTransaction().acceptDistributedTracePayload(payload);
    txB.setTransactionName(com.newrelic.api.agent.TransactionNamePriority.CUSTOM_HIGH, true, "Transaction B");
    txB.setThrowable(new Throwable(), TransactionErrorPriority.API, false);
    DefaultTracer span6Tracer = new OtherRootTracer(txB, new ClassMethodSignature("class", "span6", "()V"), null, DefaultTracer.NULL_METRIC_NAME_FORMATTER);
    txB.getTransactionActivity().tracerStarted(span6Tracer);
    span6Tracer.finish(Opcodes.ARETURN, null);
    span5Tracer.finish(Opcodes.ARETURN, null);
    // assert traceId
    SpanEventsService spanEventService = ServiceFactory.getSpanEventService();
    final TransactionData tdA = new TransactionData(tx, 1024);
    ((SpanEventsServiceImpl) spanEventService).dispatcherTransactionFinished(tdA, new TransactionStats());
    final TransactionData tdB = new TransactionData(txB, 1024);
    ((SpanEventsServiceImpl) spanEventService).dispatcherTransactionFinished(tdB, new TransactionStats());
    SamplingPriorityQueue<SpanEvent> eventPool = spanEventService.getOrCreateDistributedSamplingReservoir(APP_NAME);
    List<SpanEvent> spanEvents = eventPool.asList();
    assertEquals(5, spanEvents.size());
    TransactionEvent txAEvent = ServiceFactory.getTransactionEventsService().createEvent(tdA, new TransactionStats(), tdA.getBlameMetricName());
    TransactionEvent txBEvent = ServiceFactory.getTransactionEventsService().createEvent(tdB, new TransactionStats(), tdB.getBlameMetricName());
    SpanEvent span1 = getSpanByName(eventPool, "Java/class/span1");
    SpanEvent span2 = getSpanByName(eventPool, "Java/class/span2");
    SpanEvent span3 = getSpanByName(eventPool, "Java/class/span3");
    SpanEvent span5 = getSpanByName(eventPool, "Java/class/span5");
    SpanEvent span6 = getSpanByName(eventPool, "Java/class/span6");
    DistributedTracePayloadImpl parsedPayload = new DistributedTracePayloadParser(NewRelic.getAgent().getMetricAggregator(), ServiceFactory.getDistributedTraceService(), Agent.LOG).parse(null, payload.text());
    assertEquals(tx.getGuid(), parsedPayload.txnId);
    assertEquals(tx.sampled(), parsedPayload.sampled.booleanValue());
    assertEquals(tx.getPriority(), parsedPayload.priority, 0.0f);
    assertEquals(span2Tracer.getGuid(), parsedPayload.guid);
    assertEquals(span2.getGuid(), parsedPayload.guid);
    assertEquals(txAEvent.getTripId(), parsedPayload.traceId);
    assertEquals(txBEvent.getTripId(), parsedPayload.traceId);
    assertEquals(span1.getTraceId(), span2.getTraceId());
    assertEquals(span2.getTraceId(), span3.getTraceId());
    assertEquals(span3.getTraceId(), span5.getTraceId());
    assertEquals(span5.getTraceId(), span6.getTraceId());
    assertEquals(txAEvent.getGuid(), span1.getTransactionId());
    assertEquals(span1.getGuid(), span2.getParentId());
    assertEquals(txAEvent.getGuid(), span2.getTransactionId());
    assertEquals(span2.getGuid(), span3.getParentId());
    assertEquals(txAEvent.getGuid(), span3.getTransactionId());
    assertEquals(txAEvent.getGuid(), txBEvent.getParentId());
    assertEquals(span2.getGuid(), txBEvent.getParenSpanId());
    assertEquals(span2.getGuid(), span5.getParentId());
    assertEquals(txBEvent.getGuid(), span5.getTransactionId());
    assertEquals(span5.getGuid(), span6.getParentId());
    assertEquals(txBEvent.getGuid(), span6.getTransactionId());
    ServiceFactory.getTransactionService().transactionFinished(tdB, new TransactionStats());
    ErrorServiceImpl errorService = (ErrorServiceImpl) txB.getRPMService().getErrorService();
    DistributedSamplingPriorityQueue<ErrorEvent> reservoir = errorService.getReservoir(ServiceFactory.getConfigService().getDefaultAgentConfig().getApplicationName());
    List<ErrorEvent> errorEvents = reservoir.asList();
    assertEquals(1, errorEvents.size());
    ErrorEvent errorEvent = errorEvents.get(0);
    Map<String, Object> errorDtAtts = errorEvent.getDistributedTraceIntrinsics();
    assertEquals(txBEvent.getTripId(), errorDtAtts.get("traceId"));
    assertEquals(txBEvent.getGuid(), errorEvent.getTransactionGuid());
}
Also used : ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) DistributedTracePayload(com.newrelic.api.agent.DistributedTracePayload) DistributedTracePayloadImpl(com.newrelic.agent.tracing.DistributedTracePayloadImpl) TransactionEvent(com.newrelic.agent.service.analytics.TransactionEvent) TransactionData(com.newrelic.agent.TransactionData) BoundTransactionApiImpl(com.newrelic.agent.BoundTransactionApiImpl) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) SpanEventsService(com.newrelic.agent.service.analytics.SpanEventsService) DistributedTracePayloadParser(com.newrelic.agent.tracing.DistributedTracePayloadParser) TransactionStats(com.newrelic.agent.stats.TransactionStats) Transaction(com.newrelic.agent.Transaction) SpanEventsServiceImpl(com.newrelic.agent.service.analytics.SpanEventsServiceImpl) SpanEvent(com.newrelic.agent.model.SpanEvent) ErrorEvent(com.newrelic.agent.model.ErrorEvent) Test(org.junit.Test)

Example 28 with ErrorServiceImpl

use of com.newrelic.agent.errors.ErrorServiceImpl 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();
}
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) 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) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMService(com.newrelic.agent.MockRPMService) NormalizationServiceImpl(com.newrelic.agent.normalization.NormalizationServiceImpl)

Example 29 with ErrorServiceImpl

use of com.newrelic.agent.errors.ErrorServiceImpl 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();
}
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) 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) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMService(com.newrelic.agent.MockRPMService) NormalizationServiceImpl(com.newrelic.agent.normalization.NormalizationServiceImpl)

Example 30 with ErrorServiceImpl

use of com.newrelic.agent.errors.ErrorServiceImpl in project newrelic-java-agent by newrelic.

the class BasicRequestDispatcherTracerTest method createServiceManager.

private static void createServiceManager(AgentConfig config, Map<String, Object> configMap) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
    serviceManager.setConfigService(configService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    EnvironmentService envService = new EnvironmentServiceImpl();
    serviceManager.setEnvironmentService(envService);
    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());
    serviceManager.setAttributesService(new AttributesService());
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    statsService.start();
}
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) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) MockRPMService(com.newrelic.agent.MockRPMService) 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