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();
}
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);
}
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);
}
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;
}
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);
}
Aggregations