Search in sources :

Example 6 with TransactionDataToDistributedTraceIntrinsics

use of com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics in project newrelic-java-agent by newrelic.

the class DistributedTraceCrossAgentTest method setUp.

@Before
public void setUp() throws Exception {
    savedInstrumentation = AgentBridge.instrumentation;
    savedAgent = AgentBridge.agent;
    serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    Map<String, Object> config = new HashMap<>();
    config.put(AgentConfigImpl.APP_NAME, APP_NAME);
    Map<String, Object> dtConfig = new HashMap<>();
    dtConfig.put("enabled", true);
    config.put("distributed_tracing", dtConfig);
    Map<String, Object> spanConfig = new HashMap<>();
    spanConfig.put("collect_span_events", true);
    config.put("span_events", spanConfig);
    ConfigService configService = setupConfig(config);
    distributedTraceService = new DistributedTraceServiceImpl();
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionTraceService(new TransactionTraceService());
    serviceManager.setTransactionService(new TransactionService());
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    serviceManager.setHarvestService(new HarvestServiceImpl());
    serviceManager.setStatsService(new StatsServiceImpl());
    serviceManager.setEnvironmentService(new EnvironmentServiceImpl());
    serviceManager.setAttributesService(new AttributesService());
    AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
    AgentBridge.agent = new AgentImpl(Agent.LOG);
    serviceManager.setCoreService(mock(CoreService.class));
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    reservoirManager = new MockSpanEventReservoirManager(configService);
    spanEventsService = SpanEventsServiceFactory.builder().configService(configService).reservoirManager(reservoirManager).transactionService(serviceManager.getTransactionService()).rpmServiceManager(serviceManager.getRPMServiceManager()).spanEventCreationDecider(new SpanEventCreationDecider(configService)).environmentService(ServiceFactory.getEnvironmentService()).transactionDataToDistributedTraceIntrinsics(transactionDataToDistributedTraceIntrinsics).build();
    serviceManager.setDistributedTraceService(distributedTraceService);
    serviceManager.setSpansEventService(spanEventsService);
    ServiceFactory.getServiceManager().start();
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) HashMap(java.util.HashMap) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) CoreService(com.newrelic.agent.core.CoreService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) SpanEventCreationDecider(com.newrelic.agent.service.analytics.SpanEventCreationDecider) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) JSONObject(org.json.simple.JSONObject) Before(org.junit.Before)

Example 7 with TransactionDataToDistributedTraceIntrinsics

use of com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics in project newrelic-java-agent by newrelic.

the class SegmentTest method createServiceManager.

private static void createServiceManager(Map<String, Object> map, ExpirationService expirationService) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    AgentConfig agentConfig = AgentHelper.createAgentConfig(true, map, Collections.<String, Object>emptyMap());
    ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, map);
    serviceManager.setConfigService(configService);
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    AsyncTransactionService asyncTxService = new AsyncTransactionService();
    serviceManager.setAsyncTransactionService(asyncTxService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    EnvironmentService envService = new EnvironmentServiceImpl();
    serviceManager.setEnvironmentService(envService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
    serviceManager.setSqlTraceService(sqlTraceService);
    serviceManager.setAttributesService(new AttributesService());
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    serviceManager.setExpirationService(expirationService);
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) TransactionService(com.newrelic.agent.TransactionService) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) ThreadService(com.newrelic.agent.ThreadService) AgentConfig(com.newrelic.agent.config.AgentConfig) 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)

Example 8 with TransactionDataToDistributedTraceIntrinsics

use of com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics in project newrelic-java-agent by newrelic.

the class TransactionTimesTest 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 = AgentHelper.createAgentConfig(true, map, Collections.<String, Object>emptyMap());
    ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, map);
    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);
    StatsServiceImpl statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
    serviceManager.setSqlTraceService(sqlTraceService);
    serviceManager.setAttributesService(new AttributesService());
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) 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) AgentConfig(com.newrelic.agent.config.AgentConfig) 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)

Example 9 with TransactionDataToDistributedTraceIntrinsics

use of com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics in project newrelic-java-agent by newrelic.

the class TransactionServiceTest method createServiceManager.

private MockServiceManager createServiceManager(Map<String, Object> map) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
    serviceManager.setConfigService(configService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    TransactionService transactionService = new TransactionService();
    transactionService.start();
    serviceManager.setTransactionService(transactionService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    ExtensionService extensionService = new ExtensionService(configService, ExtensionsLoadedListener.NOOP);
    serviceManager.setExtensionService(extensionService);
    TracerService tracerService = new TracerService();
    serviceManager.setTracerService(tracerService);
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    EnvironmentService environmentService = new EnvironmentServiceImpl();
    serviceManager.setEnvironmentService(environmentService);
    AttributesService attributesService = new AttributesService();
    serviceManager.setAttributesService(attributesService);
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    return serviceManager;
}
Also used : ExtensionService(com.newrelic.agent.extension.ExtensionService) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService)

Example 10 with TransactionDataToDistributedTraceIntrinsics

use of com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics in project newrelic-java-agent by newrelic.

the class DataCollectionConfigCrossAgentTest method createAndVerifyTransactionEvent.

private void createAndVerifyTransactionEvent(Long expectedCount, Long expectedEndpointCount) {
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
    TransactionEventsService transactionEventsService = new TransactionEventsService(transactionDataToDistributedTraceIntrinsics);
    serviceManager.setTransactionEventsService(transactionEventsService);
    long eventsToCreate = 1;
    if (expectedCount > 1) {
        eventsToCreate = expectedCount;
    }
    for (long i = 0; i < eventsToCreate; i++) {
        TransactionData transactionData = EventTestHelper.generateTransactionDataAndComplete(Collections.<String, Object>emptyMap(), APP_NAME);
        TransactionStats transactionStats = new TransactionStats();
        transactionEventsService.dispatcherTransactionFinished(transactionData, transactionStats);
    }
    // Verify that the correct number of events were stored in the reservoir
    DistributedSamplingPriorityQueue<TransactionEvent> eventQueue = transactionEventsService.getOrCreateDistributedSamplingReservoir(APP_NAME);
    assertNotNull(eventQueue);
    assertEquals(expectedCount.intValue(), eventQueue.size());
    // Verify that we sent (or didn't send) the appropriate events
    transactionEventsService.harvestEvents(APP_NAME);
    int transactionEventsSeen = rpmService.getTransactionEventsSeen();
    assertEquals(expectedEndpointCount.intValue(), transactionEventsSeen);
}
Also used : TransactionEvent(com.newrelic.agent.service.analytics.TransactionEvent) TransactionStats(com.newrelic.agent.stats.TransactionStats) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics)

Aggregations

TransactionDataToDistributedTraceIntrinsics (com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics)15 TransactionEventsService (com.newrelic.agent.service.analytics.TransactionEventsService)15 AttributesService (com.newrelic.agent.attributes.AttributesService)13 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)13 EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)12 ConfigService (com.newrelic.agent.config.ConfigService)11 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)11 DistributedTraceServiceImpl (com.newrelic.agent.tracing.DistributedTraceServiceImpl)11 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)9 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)8 TransactionService (com.newrelic.agent.TransactionService)7 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)7 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)6 MockServiceManager (com.newrelic.agent.MockServiceManager)6 StatsService (com.newrelic.agent.stats.StatsService)6 ThreadService (com.newrelic.agent.ThreadService)5 AsyncTransactionService (com.newrelic.agent.service.async.AsyncTransactionService)5 HarvestService (com.newrelic.agent.HarvestService)4 MockCoreService (com.newrelic.agent.MockCoreService)4 MockHarvestService (com.newrelic.agent.MockHarvestService)4