use of com.newrelic.agent.config.ConfigService 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.config.ConfigService in project newrelic-java-agent by newrelic.
the class StackTracesTest method testToStringListRemoveParent2.
@Test
public void testToStringListRemoveParent2() {
// need configuration service set
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
Map<String, Object> configMap = new HashMap<>();
AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
serviceManager.setConfigService(configService);
// get stack traces
StackTraceElement[] parentTraceArray = Thread.currentThread().getStackTrace();
List<StackTraceElement> parentTrace = changeComNewrelic(parentTraceArray);
StackTraceElement[] childTraceArray = anotherMethod1();
List<StackTraceElement> childTrace = changeComNewrelic(childTraceArray);
List<StackTraceElement> childScrubbed = StackTraces.scrubAndTruncate(childTrace);
List<String> trimmed = StackTraces.toStringListRemoveParent(childScrubbed, parentTrace);
Assert.assertEquals(3, trimmed.size());
Assert.assertTrue("0 failed " + trimmed.get(0), trimmed.get(0).startsWith("hello.howdy.util.StackTracesTest.anotherMethod3("));
Assert.assertTrue("1 failed" + trimmed.get(1), trimmed.get(1).startsWith("hello.howdy.util.StackTracesTest.anotherMethod2("));
Assert.assertTrue("2 failed" + trimmed.get(2), trimmed.get(2).startsWith("hello.howdy.util.StackTracesTest.anotherMethod1("));
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class StackTracesTest method testToStringListRemoveParent1.
@Test
public void testToStringListRemoveParent1() {
// need configuration service set
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
Map<String, Object> configMap = new HashMap<>();
AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
serviceManager.setConfigService(configService);
// get stack traces
List<StackTraceElement> parentTrace = generateStack(5, 15);
List<StackTraceElement> childTrace = generateStack(0, 10);
List<String> trimmed = StackTraces.toStringListRemoveParent(childTrace, parentTrace);
Assert.assertEquals(5, trimmed.size());
for (int i = 0; i < 5; i++) {
Assert.assertEquals("Test.method(file:" + i + ")", trimmed.get(i));
}
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class UtilizationCrossAgentTests method setConfig.
/*
* Create a mock service manager with a config service with the given utilization values
*/
private static void setConfig(String billingHostname, Long totalRam, Integer logicalProcessors) {
Map<String, Object> config = new HashMap<>();
Map<String, Object> values = new HashMap<>();
values.put("billing_hostname", billingHostname);
values.put("total_ram_mib", totalRam);
values.put("logical_processors", logicalProcessors);
config.put(UtilizationDataConfig.PROPERTY_NAME, values);
config.put("app_name", "CATs");
ConfigService configService = new MockConfigService(AgentConfigImpl.createAgentConfig(config));
MockServiceManager mockServiceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(mockServiceManager);
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class StackTracesTest method testToStringListRemoveParentNullParent.
@Test
public void testToStringListRemoveParentNullParent() {
// need configuration service set
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
Map<String, Object> configMap = new HashMap<>();
AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
serviceManager.setConfigService(configService);
// get stack traces
List<StackTraceElement> parentTrace = null;
List<StackTraceElement> childTrace = generateStack(0, 10);
List<String> trimmed = StackTraces.toStringListRemoveParent(childTrace, parentTrace);
Assert.assertEquals(childTrace.size(), trimmed.size());
for (int i = 0; i < childTrace.size(); i++) {
Assert.assertEquals(childTrace.get(i).toString(), trimmed.get(i));
}
}
Aggregations