use of com.newrelic.agent.environment.EnvironmentService 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.environment.EnvironmentService 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.environment.EnvironmentService in project newrelic-java-agent by newrelic.
the class TransactionAppNamingTest method createServiceManager.
@Before
public void createServiceManager() throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
// Needed by TransactionService
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
// Needed by TransactionTraceService
Map<String, Object> configMap = createConfigMap();
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
serviceManager.setConfigService(configService);
// Needed by Transaction
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
EnvironmentService envService = new EnvironmentServiceImpl();
serviceManager.setEnvironmentService(envService);
// Null pointers if not set
serviceManager.setStatsService(Mockito.mock(StatsService.class));
// Needed by Transaction
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
serviceManager.setAttributesService(new AttributesService());
// Needed by Transaction
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceManager.setRPMService(rpmService);
}
use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.
the class SpanEventsServiceTest method before.
@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
serviceManager = new MockServiceManager();
Map<String, Object> localSettings = new HashMap<>();
localSettings.put(AgentConfigImpl.APP_NAME, APP_NAME);
localSettings.put("distributed_tracing", Collections.singletonMap("enabled", true));
localSettings.put("span_events", Collections.singletonMap("collect_span_events", true));
when(spanEventCreationDecider.shouldCreateSpans(any(TransactionData.class))).thenReturn(true);
AgentConfig agentConfig = AgentHelper.createAgentConfig(true, localSettings, new HashMap<String, Object>());
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, localSettings);
serviceManager.setConfigService(configService);
ServiceFactory.setServiceManager(serviceManager);
serviceManager.setTransactionService(new TransactionService());
serviceManager.setThreadService(new ThreadService());
final MockSpanEventReservoirManager reservoirManager = new MockSpanEventReservoirManager(configService);
Consumer<SpanEvent> backendConsumer = spanEvent -> reservoirManager.getOrCreateReservoir(APP_NAME).add(spanEvent);
SpanErrorBuilder defaultSpanErrorBuilder = new SpanErrorBuilder(new ErrorAnalyzerImpl(agentConfig.getErrorCollectorConfig()), new ErrorMessageReplacer(agentConfig.getStripExceptionConfig()));
Map<String, SpanErrorBuilder> map = new HashMap<>();
map.put(agentConfig.getApplicationName(), defaultSpanErrorBuilder);
EnvironmentService environmentService = mock(EnvironmentService.class, RETURNS_DEEP_STUBS);
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
when(transactionDataToDistributedTraceIntrinsics.buildDistributedTracingIntrinsics(any(TransactionData.class), anyBoolean())).thenReturn(Collections.<String, Object>emptyMap());
TracerToSpanEvent tracerToSpanEvent = new TracerToSpanEvent(map, environmentService, transactionDataToDistributedTraceIntrinsics, defaultSpanErrorBuilder);
SpanEventsServiceImpl spanEventsService = SpanEventsServiceImpl.builder().agentConfig(agentConfig).reservoirManager(reservoirManager).collectorSender(mock(CollectorSpanEventSender.class)).eventBackendStorage(backendConsumer).spanEventCreationDecider(spanEventCreationDecider).tracerToSpanEvent(tracerToSpanEvent).build();
serviceManager.setSpansEventService(spanEventsService);
serviceManager.setAttributesService(new AttributesService());
}
use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.
the class RPMConnectionServiceTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
AgentHelper.initializeConfig();
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
Map<String, Object> settings = AgentConfigFactoryTest.createStagingMap();
AgentConfig config = AgentConfigFactory.createAgentConfig(settings, null, null);
Environment env = new Environment(config, "c:\\test\\log");
EnvironmentService envService = Mockito.mock(EnvironmentService.class, new Returns(env));
serviceManager.setEnvironmentService(envService);
ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(settings);
serviceManager.setConfigService(configService);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
rpmConnectionService = new TestRPMConnectionService();
}
Aggregations