Search in sources :

Example 16 with EnvironmentServiceImpl

use of com.newrelic.agent.environment.EnvironmentServiceImpl in project newrelic-java-agent by newrelic.

the class TransactionEventsServiceTest method testTransactionEventFasterHarvest.

@Test
public void testTransactionEventFasterHarvest() throws Exception {
    Map<String, Object> config = new HashMap<>();
    config.put(AgentConfigImpl.APP_NAME, APP_NAME);
    EventTestHelper.setAppName(APP_NAME);
    EventTestHelper.createServiceManager(config);
    service = new TransactionEventsService(mock(TransactionDataToDistributedTraceIntrinsics.class));
    ((MockServiceManager) ServiceFactory.getServiceManager()).setTransactionEventsService(service);
    environmentService = new EnvironmentServiceImpl();
    ((MockServiceManager) ServiceFactory.getServiceManager()).setEnvironmentService(environmentService);
    ServiceManager serviceManager = spy(ServiceFactory.getServiceManager());
    ServiceFactory.setServiceManager(serviceManager);
    HarvestServiceImpl harvestService = spy(new HarvestServiceImpl());
    doReturn(harvestService).when(serviceManager).getHarvestService();
    doReturn(0L).when(harvestService).getInitialDelay();
    service.addHarvestableToService(APP_NAME);
    service.configureHarvestables(60, 3);
    assertEquals(3, service.getMaxSamplesStored());
    service.doStart();
    Map<String, Object> connectionInfo = new HashMap<>();
    Map<String, Object> eventHarvest = new HashMap<>();
    Map<String, Object> harvestLimits = new HashMap<>();
    // 5 is the lowest allowable value
    eventHarvest.put("report_period_ms", 5000L);
    eventHarvest.put("harvest_limits", harvestLimits);
    harvestLimits.put("analytic_event_data", 100L);
    connectionInfo.put("event_harvest_config", eventHarvest);
    harvestService.startHarvestables(ServiceFactory.getRPMService(), AgentConfigImpl.createAgentConfig(connectionInfo));
    getEventData(APP_NAME);
    Thread.sleep(500);
    DistributedSamplingPriorityQueue<TransactionEvent> currentEventData = createAndSendTransaction();
    assertEquals(1, currentEventData.size());
    Thread.sleep(6000);
    checkForEvent();
    assertEquals(1, currentEventData.size());
    createAndSendTransaction();
    Thread.sleep(6000);
    checkForEvent();
}
Also used : HashMap(java.util.HashMap) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) HarvestServiceImpl(com.newrelic.agent.HarvestServiceImpl) Test(org.junit.Test)

Example 17 with EnvironmentServiceImpl

use of com.newrelic.agent.environment.EnvironmentServiceImpl in project newrelic-java-agent by newrelic.

the class DataCollectionConfigCrossAgentTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    savedInstrumentation = AgentBridge.instrumentation;
    savedAgent = AgentBridge.agent;
    serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    defaultConfig = new HashMap<>();
    defaultConfig.put(AgentConfigImpl.APP_NAME, APP_NAME);
    Map<String, Object> dtConfig = new HashMap<>();
    dtConfig.put("enabled", true);
    defaultConfig.put("distributed_tracing", dtConfig);
    configService = setupConfig(defaultConfig);
    serviceManager.setTransactionTraceService(new TransactionTraceService());
    serviceManager.setTransactionService(new TransactionService());
    serviceManager.setHarvestService(new HarvestServiceImpl());
    serviceManager.setStatsService(new StatsServiceImpl());
    serviceManager.setEnvironmentService(new EnvironmentServiceImpl());
    serviceManager.setAttributesService(new AttributesService());
    AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
    AgentBridge.agent = new AgentImpl(Agent.LOG);
    serviceManager.setCoreService(mock(CoreService.class));
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    ServiceFactory.getServiceManager().start();
    rpmService = (MockRPMService) rpmServiceManager.getRPMService();
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) HashMap(java.util.HashMap) AttributesService(com.newrelic.agent.attributes.AttributesService) CoreService(com.newrelic.agent.core.CoreService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) JSONObject(org.json.simple.JSONObject) BeforeClass(org.junit.BeforeClass)

Example 18 with EnvironmentServiceImpl

use of com.newrelic.agent.environment.EnvironmentServiceImpl in project newrelic-java-agent by newrelic.

the class BasicRequestDispatcherTracerTest method createServiceManager.

private static void createServiceManager(AgentConfig config, Map<String, Object> configMap) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
    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);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
    serviceManager.setSqlTraceService(sqlTraceService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
    rpmServiceManager.setRPMService(rpmService);
    configService.start();
    serviceManager.setNormalizationService(new NormalizationServiceImpl());
    serviceManager.setAttributesService(new AttributesService());
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    statsService.start();
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) 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) 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) MockRPMService(com.newrelic.agent.MockRPMService) NormalizationServiceImpl(com.newrelic.agent.normalization.NormalizationServiceImpl)

Example 19 with EnvironmentServiceImpl

use of com.newrelic.agent.environment.EnvironmentServiceImpl in project newrelic-java-agent by newrelic.

the class SqlTraceServiceTest method createServiceManager.

private MockServiceManager createServiceManager(Map<String, Object> configMap) throws Exception {
    AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
    serviceManager.setConfigService(configService);
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    ClassTransformerService classTransformerService = Mockito.mock(ClassTransformerService.class);
    serviceManager.setClassTransformerService(classTransformerService);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    DatabaseService dbService = new DatabaseService();
    serviceManager.setDatabaseService(dbService);
    EnvironmentService envService = new EnvironmentServiceImpl();
    serviceManager.setEnvironmentService(envService);
    SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
    serviceManager.setSqlTraceService(sqlTraceService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    serviceManager.setAttributesService(new AttributesService());
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmService.setEverConnected(true);
    rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
    rpmServiceManager.setRPMService(rpmService);
    configService.start();
    serviceManager.start();
    sqlTraceService.start();
    return serviceManager;
}
Also used : MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) DatabaseService(com.newrelic.agent.database.DatabaseService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) AgentConfig(com.newrelic.agent.config.AgentConfig) ThreadService(com.newrelic.agent.ThreadService) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) ClassTransformerService(com.newrelic.agent.instrumentation.ClassTransformerService) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockCoreService(com.newrelic.agent.MockCoreService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) MockRPMService(com.newrelic.agent.MockRPMService)

Example 20 with EnvironmentServiceImpl

use of com.newrelic.agent.environment.EnvironmentServiceImpl in project newrelic-java-agent by newrelic.

the class W3CTraceContextCrossAgentTest method setup.

@Before
public void setup() throws Exception {
    savedInstrumentation = AgentBridge.instrumentation;
    savedAgent = AgentBridge.agent;
    serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    Map<String, Object> config = Maps.newHashMap();
    config.put(AgentConfigImpl.APP_NAME, APP_NAME);
    Map<String, Object> dtConfig = Maps.newHashMap();
    dtConfig.put("enabled", true);
    dtConfig.put("exclude_newrelic_header", true);
    config.put("distributed_tracing", dtConfig);
    Map<String, Object> spanConfig = Maps.newHashMap();
    spanConfig.put("collect_span_events", true);
    config.put("span_events", spanConfig);
    ConfigService configService = setupConfig(config);
    serviceManager.setTransactionTraceService(new TransactionTraceService());
    serviceManager.setTransactionService(new TransactionService());
    distributedTraceService = new DistributedTraceServiceImpl();
    transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    serviceManager.setHarvestService(new HarvestServiceImpl());
    statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    serviceManager.setEnvironmentService(new EnvironmentServiceImpl());
    serviceManager.setAttributesService(new AttributesService());
    AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
    AgentBridge.agent = new AgentImpl(Agent.LOG);
    CoreService coreService = Mockito.mock(CoreService.class);
    when(coreService.isEnabled()).thenReturn(true);
    serviceManager.setCoreService(coreService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    ServiceFactory.getServiceManager().start();
    ServiceFactory.getTransactionService().addTransactionListener(distributedTraceService);
    spanEventService = createSpanEventService(configService, transactionDataToDistributedTraceIntrinsics);
    serviceManager.setDistributedTraceService(distributedTraceService);
    serviceManager.setSpansEventService(spanEventService);
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) CoreService(com.newrelic.agent.core.CoreService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) JSONObject(org.json.simple.JSONObject) Before(org.junit.Before)

Aggregations

EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)20 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)18 AttributesService (com.newrelic.agent.attributes.AttributesService)17 ConfigService (com.newrelic.agent.config.ConfigService)13 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)13 TransactionDataToDistributedTraceIntrinsics (com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics)12 TransactionEventsService (com.newrelic.agent.service.analytics.TransactionEventsService)12 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)12 DistributedTraceServiceImpl (com.newrelic.agent.tracing.DistributedTraceServiceImpl)12 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)9 StatsService (com.newrelic.agent.stats.StatsService)9 MockServiceManager (com.newrelic.agent.MockServiceManager)8 TransactionService (com.newrelic.agent.TransactionService)8 HarvestService (com.newrelic.agent.HarvestService)7 ThreadService (com.newrelic.agent.ThreadService)7 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)7 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)6 AsyncTransactionService (com.newrelic.agent.service.async.AsyncTransactionService)6 MockHarvestService (com.newrelic.agent.MockHarvestService)5 AgentConfig (com.newrelic.agent.config.AgentConfig)5