Search in sources :

Example 36 with ConfigService

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

the class CalculatePathHashTest 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)

Example 37 with ConfigService

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

the class CrossProcessAndSyntheticsConfigTest method testConfig.

// The "expected value" arguments are all about the newrelic.yml. We're not varying the collector JSON here.
public void testConfig(String ymlFilePath, boolean expectedValueOfCatEnable, boolean expectedValueOfBrowserEnabled) throws Exception {
    System.setProperty("newrelic.config.file", ymlFilePath);
    ConfigService configService = ConfigServiceFactory.createConfigService(mock(Logger.class), false);
    AgentConfig agentConfig = configService.getAgentConfig(appName);
    assertEquals(appName, agentConfig.getApplicationName());
    assertTrue(agentConfig instanceof AgentConfigImpl);
    assertTrue(configService instanceof ConfigServiceImpl);
    IRPMService rpmService = mock(IRPMService.class);
    Mockito.when(rpmService.getApplicationName()).thenReturn(appName);
    org.json.simple.parser.JSONParser parser = new org.json.simple.parser.JSONParser();
    @SuppressWarnings("unchecked") Map<String, Object> serverData = (Map<String, Object>) parser.parse(collectorJson);
    ((ConfigServiceImpl) configService).connected(rpmService, serverData);
    assertEquals(configService.getAgentConfig(appName).getBrowserMonitoringConfig().isAutoInstrumentEnabled(), expectedValueOfBrowserEnabled);
    assertEquals(configService.getAgentConfig(appName).getCrossProcessConfig().isCrossApplicationTracing(), expectedValueOfCatEnable);
    String s = configService.getAgentConfig(appName).getValue("cross_application_tracer.encoding_key");
    assertEquals(s, encodingKey);
}
Also used : Logger(com.newrelic.api.agent.Logger) AgentConfig(com.newrelic.agent.config.AgentConfig) AgentConfigImpl(com.newrelic.agent.config.AgentConfigImpl) ConfigService(com.newrelic.agent.config.ConfigService) ConfigServiceImpl(com.newrelic.agent.config.ConfigServiceImpl) Map(java.util.Map)

Example 38 with ConfigService

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

the class CrossProcessStateCatApiTest method setUpServiceManager.

private void setUpServiceManager() throws Exception {
    ImmutableMap<String, Object> distributedTracingSettings = ImmutableMap.<String, Object>builder().put(DistributedTracingConfig.ENABLED, Boolean.FALSE).build();
    Map<String, Object> configMap = ImmutableMap.<String, Object>builder().put(AgentConfigImpl.APP_NAME, "TransactionAppNamingTest").put(AgentConfigImpl.DISTRIBUTED_TRACING, distributedTracingSettings).build();
    ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(configMap);
    serviceManager = new MockServiceManager(configService);
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) Matchers.anyString(org.mockito.Matchers.anyString)

Example 39 with ConfigService

use of com.newrelic.agent.config.ConfigService 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 40 with ConfigService

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

the class DistributedTraceCrossAgentTest method setupConfig.

private ConfigService setupConfig(Map<String, Object> config) {
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(config), Collections.<String, Object>emptyMap());
    serviceManager.setConfigService(configService);
    return configService;
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService)

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