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);
}
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);
}
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();
}
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();
}
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;
}
Aggregations