Search in sources :

Example 26 with ConfigService

use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.

the class ProfileTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    Map<String, Object> map = new HashMap<>();
    AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(map);
    ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, map);
    serviceManager.setConfigService(configService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
}
Also used : ThreadService(com.newrelic.agent.ThreadService) AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) TransactionService(com.newrelic.agent.TransactionService) HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) BeforeClass(org.junit.BeforeClass)

Example 27 with ConfigService

use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.

the class CPUSamplerTest method createServiceManager.

private MockServiceManager createServiceManager(Map<String, Object> map) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
    serviceManager.setConfigService(configService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    ProfilerService profilerService = new ProfilerService();
    serviceManager.setProfilerService(profilerService);
    return serviceManager;
}
Also used : ThreadService(com.newrelic.agent.ThreadService) ConfigService(com.newrelic.agent.config.ConfigService) TransactionService(com.newrelic.agent.TransactionService) MockServiceManager(com.newrelic.agent.MockServiceManager) ProfilerService(com.newrelic.agent.profile.ProfilerService)

Example 28 with ConfigService

use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.

the class ServiceManagerTest method dynamicServices.

@Test
public void dynamicServices() throws Exception {
    AgentHelper.initializeConfig();
    CoreService agent = new MockCoreService();
    ConfigService configService = ConfigServiceFactory.createConfigService(mock(Logger.class), false);
    ServiceManager serviceManager = new ServiceManagerImpl(agent, configService);
    Service testService = new TestService("My Service");
    serviceManager.addService(testService);
    Assert.assertEquals(testService, serviceManager.getService(testService.getName()));
    Assert.assertFalse(testService.isStarted());
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) MockCoreService(com.newrelic.agent.MockCoreService) CoreService(com.newrelic.agent.core.CoreService) MockCoreService(com.newrelic.agent.MockCoreService) CoreService(com.newrelic.agent.core.CoreService) MockCoreService(com.newrelic.agent.MockCoreService) ConfigService(com.newrelic.agent.config.ConfigService) Logger(com.newrelic.api.agent.Logger) Test(org.junit.Test)

Example 29 with ConfigService

use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.

the class CollectorSpanEventReservoirManagerTest method attemptToSendDoesSend.

@Test
public void attemptToSendDoesSend() {
    ConfigService mockConfigService = mock21Samples();
    CollectorSpanEventReservoirManager target = initWith25Tries(mockConfigService);
    // boolean arrays can be final so that nested classes can use them
    final boolean[] resultFlags = new boolean[] { false };
    ReservoirManager.HarvestResult harvestResult = target.attemptToSendReservoir(APP_NAME, (appName, reservoirSize, eventsSeen, events) -> {
        assertEquals(APP_NAME, appName);
        assertEquals(21, reservoirSize);
        assertEquals(25, eventsSeen);
        assertEquals(21, events.size());
        resultFlags[0] = true;
    }, mock(Logger.class));
    assertTrue("It doesn't seem like the sendEvents call succeeded.", resultFlags[0]);
    assertEquals(25, harvestResult.seen);
    assertEquals(21, harvestResult.sent);
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) ReservoirManager(com.newrelic.agent.interfaces.ReservoirManager) Logger(com.newrelic.api.agent.Logger) Test(org.junit.Test)

Example 30 with ConfigService

use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.

the class CollectorSpanEventReservoirManagerTest method doesNotSendWithEmptyReservoir.

@Test
public void doesNotSendWithEmptyReservoir() {
    ConfigService mockConfigService = mock21Samples();
    CollectorSpanEventReservoirManager target = new CollectorSpanEventReservoirManager(mockConfigService);
    final boolean[] wasSent = new boolean[] { false };
    ReservoirManager.HarvestResult harvestResult = target.attemptToSendReservoir(APP_NAME, (appName, reservoirSize, eventsSeen, events) -> wasSent[0] = true, mock(Logger.class));
    assertNull(harvestResult);
    assertFalse(wasSent[0]);
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) ReservoirManager(com.newrelic.agent.interfaces.ReservoirManager) Logger(com.newrelic.api.agent.Logger) 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