Search in sources :

Example 46 with ConfigService

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);
}
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 47 with ConfigService

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("));
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) Test(org.junit.Test)

Example 48 with ConfigService

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));
    }
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) Test(org.junit.Test)

Example 49 with ConfigService

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);
}
Also used : MockConfigService(com.newrelic.agent.MockConfigService) ConfigService(com.newrelic.agent.config.ConfigService) HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) JSONObject(org.json.simple.JSONObject) MockConfigService(com.newrelic.agent.MockConfigService)

Example 50 with ConfigService

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));
    }
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) Test(org.junit.Test)

Aggregations

ConfigService (com.newrelic.agent.config.ConfigService)95 MockServiceManager (com.newrelic.agent.MockServiceManager)57 TransactionService (com.newrelic.agent.TransactionService)36 AgentConfig (com.newrelic.agent.config.AgentConfig)36 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)32 ThreadService (com.newrelic.agent.ThreadService)31 AttributesService (com.newrelic.agent.attributes.AttributesService)30 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)29 HarvestService (com.newrelic.agent.HarvestService)24 MockHarvestService (com.newrelic.agent.MockHarvestService)23 HashMap (java.util.HashMap)23 StatsService (com.newrelic.agent.stats.StatsService)21 MockCoreService (com.newrelic.agent.MockCoreService)20 MockRPMService (com.newrelic.agent.MockRPMService)20 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)20 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)20 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)19 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)17 Test (org.junit.Test)15 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)14