Search in sources :

Example 11 with EnvironmentServiceImpl

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

the class DistributedTraceCrossAgentTest method setUp.

@Before
public void setUp() throws Exception {
    savedInstrumentation = AgentBridge.instrumentation;
    savedAgent = AgentBridge.agent;
    serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    Map<String, Object> config = new HashMap<>();
    config.put(AgentConfigImpl.APP_NAME, APP_NAME);
    Map<String, Object> dtConfig = new HashMap<>();
    dtConfig.put("enabled", true);
    config.put("distributed_tracing", dtConfig);
    Map<String, Object> spanConfig = new HashMap<>();
    spanConfig.put("collect_span_events", true);
    config.put("span_events", spanConfig);
    ConfigService configService = setupConfig(config);
    distributedTraceService = new DistributedTraceServiceImpl();
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionTraceService(new TransactionTraceService());
    serviceManager.setTransactionService(new TransactionService());
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    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);
    reservoirManager = new MockSpanEventReservoirManager(configService);
    spanEventsService = SpanEventsServiceFactory.builder().configService(configService).reservoirManager(reservoirManager).transactionService(serviceManager.getTransactionService()).rpmServiceManager(serviceManager.getRPMServiceManager()).spanEventCreationDecider(new SpanEventCreationDecider(configService)).environmentService(ServiceFactory.getEnvironmentService()).transactionDataToDistributedTraceIntrinsics(transactionDataToDistributedTraceIntrinsics).build();
    serviceManager.setDistributedTraceService(distributedTraceService);
    serviceManager.setSpansEventService(spanEventsService);
    ServiceFactory.getServiceManager().start();
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) HashMap(java.util.HashMap) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) CoreService(com.newrelic.agent.core.CoreService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) SpanEventCreationDecider(com.newrelic.agent.service.analytics.SpanEventCreationDecider) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) JSONObject(org.json.simple.JSONObject) Before(org.junit.Before)

Example 12 with EnvironmentServiceImpl

use of com.newrelic.agent.environment.EnvironmentServiceImpl 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);
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) TransactionService(com.newrelic.agent.TransactionService) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) 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 13 with EnvironmentServiceImpl

use of com.newrelic.agent.environment.EnvironmentServiceImpl 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 14 with EnvironmentServiceImpl

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

the class TransactionServiceTest method createServiceManager.

private MockServiceManager createServiceManager(Map<String, Object> map) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
    serviceManager.setConfigService(configService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    TransactionService transactionService = new TransactionService();
    transactionService.start();
    serviceManager.setTransactionService(transactionService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    ExtensionService extensionService = new ExtensionService(configService, ExtensionsLoadedListener.NOOP);
    serviceManager.setExtensionService(extensionService);
    TracerService tracerService = new TracerService();
    serviceManager.setTracerService(tracerService);
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    EnvironmentService environmentService = new EnvironmentServiceImpl();
    serviceManager.setEnvironmentService(environmentService);
    AttributesService attributesService = new AttributesService();
    serviceManager.setAttributesService(attributesService);
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    serviceManager.setDistributedTraceService(distributedTraceService);
    TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
    serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
    return serviceManager;
}
Also used : ExtensionService(com.newrelic.agent.extension.ExtensionService) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService)

Example 15 with EnvironmentServiceImpl

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

the class TransactionAppNamingTest 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);
}
Also used : ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) AttributesService(com.newrelic.agent.attributes.AttributesService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) 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