use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.
the class CommandParserThreadProfilerTest method createServiceManager.
private MockServiceManager createServiceManager(Map<String, Object> config) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(config), config);
serviceManager.setConfigService(configService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
RPMConnectionService rpmConnectionService = new RPMConnectionServiceImpl();
serviceManager.setRPMConnectionService(rpmConnectionService);
ProfilerService profilerService = new ProfilerService();
serviceManager.setProfilerService(profilerService);
EnvironmentService envService = new EnvironmentServiceImpl();
serviceManager.setEnvironmentService(envService);
HarvestService harvestService = new HarvestServiceImpl();
serviceManager.setHarvestService(harvestService);
return serviceManager;
}
use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.
the class TracerToSpanEventTest method setup.
@Before
public void setup() {
transactionAgentAttributes = new HashMap<>();
transactionUserAttributes = new HashMap<>();
tracerAgentAttributes = new HashMap<>();
tracerUserAttributes = new HashMap<>();
expectedAgentAttributes = new HashMap<>();
expectedUserAttributes = new HashMap<>();
expectedAgentAttributes.put("error.class", "0");
expectedAgentAttributes.put("port", 9191);
expectedIntrinsicAttributes = new HashMap<>();
expectedIntrinsicAttributes.put("traceId", traceId);
expectedIntrinsicAttributes.put("duration", (float) duration / TimeConversion.NANOSECONDS_PER_SECOND);
expectedIntrinsicAttributes.put("type", "Span");
expectedIntrinsicAttributes.put("category", "generic");
expectedIntrinsicAttributes.put("sampled", sampled);
expectedIntrinsicAttributes.put("nr.entryPoint", true);
expectedIntrinsicAttributes.put("timestamp", timestamp);
expectedIntrinsicAttributes.put("priority", priority);
expectedIntrinsicAttributes.put("transaction.name", txnName.getName());
tracer = mock(Tracer.class);
txnData = mock(TransactionData.class);
spanErrorBuilder = mock(SpanErrorBuilder.class);
spanError = mock(SpanError.class);
spanProxy = mock(SpanProxy.class);
throwable = mock(TransactionThrowable.class);
environmentService = mock(EnvironmentService.class);
environment = mock(Environment.class);
transactionDataToDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
txnStats = mock(TransactionStats.class, RETURNS_DEEP_STUBS);
errorBuilderMap = new HashMap<>();
errorBuilderMap.put(appName, spanErrorBuilder);
when(tracer.getDuration()).thenReturn(duration);
when(tracer.getStartTimeInMillis()).thenReturn(timestamp);
when(tracer.getAgentAttributes()).thenReturn(tracerAgentAttributes);
when(tracer.getCustomAttributes()).thenReturn(tracerUserAttributes);
when(spanErrorBuilder.buildSpanError(tracer, isRoot, responseStatus, statusMessage, throwable)).thenReturn(spanError);
when(spanErrorBuilder.areErrorsEnabled()).thenReturn(true);
when(txnData.getApplicationName()).thenReturn(appName);
when(txnData.getResponseStatus()).thenReturn(responseStatus);
when(txnData.getStatusMessage()).thenReturn(statusMessage);
when(txnData.getThrowable()).thenReturn(throwable);
when(txnData.getPriority()).thenReturn(priority);
when(txnData.sampled()).thenReturn(sampled);
when(txnData.getSpanProxy()).thenReturn(spanProxy);
when(txnData.getPriorityTransactionName()).thenReturn(txnName);
when(txnData.getUserAttributes()).thenReturn(transactionUserAttributes);
when(spanProxy.getOrCreateTraceId()).thenReturn(traceId);
when(environmentService.getEnvironment()).thenReturn(environment);
when(environment.getAgentIdentity()).thenReturn(new AgentIdentity("dispatcher", "1.2.3", 9191, "myInstance"));
}
use of com.newrelic.agent.environment.EnvironmentService in project newrelic-java-agent by newrelic.
the class CalculatePathHashTest 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 HarvestServiceTest method setup.
@Before
public void setup() throws Exception {
AgentHelper.initializeConfig();
ConfigService configService = ConfigServiceFactory.createConfigService(mock(Logger.class), false);
MockServiceManager serviceManager = new MockServiceManager(configService);
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));
Mockito.doNothing().when(envService).stop();
serviceManager.setEnvironmentService(envService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
statsService.start();
}
use of com.newrelic.agent.environment.EnvironmentService 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);
}
Aggregations