use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class CollectorHostnameCrossAgentTest method setConfig.
private void setConfig(String licenseKey, String overrideHost) {
Map<String, Object> config = new HashMap<>();
config.put("license_key", licenseKey);
if (overrideHost != null) {
config.put("host", overrideHost);
}
config.put("app_name", "Unit Test");
ConfigService configService = new MockConfigService(AgentConfigImpl.createAgentConfig(config));
MockServiceManager mockServiceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(mockServiceManager);
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class CrossProcessStateCatApiTest method trustAppAndGetTracer.
private CatTestCustomTracer trustAppAndGetTracer(String accountID) {
ImmutableMap<String, Object> crossProcessSettings = ImmutableMap.<String, Object>builder().put(CrossProcessConfigImpl.ENCODING_KEY, ENCODING_KEY).put(CrossProcessConfigImpl.ENABLED, Boolean.TRUE).put(CrossProcessConfigImpl.TRUSTED_ACCOUNT_IDS, accountID).put(CrossProcessConfigImpl.CROSS_PROCESS_ID, accountID + "#878").build();
// Disable DT for CAT specific tests
ImmutableMap<String, Object> distributedTracingSettings = ImmutableMap.<String, Object>builder().put(DistributedTracingConfig.ENABLED, Boolean.FALSE).build();
Map<String, Object> settings = new HashMap<>();
settings.put(AgentConfigImpl.CROSS_APPLICATION_TRACER, crossProcessSettings);
settings.put(AgentConfigImpl.APP_NAME, "TransactionAppNamingTest");
settings.put(AgentConfigImpl.DISTRIBUTED_TRACING, distributedTracingSettings);
ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(settings);
serviceManager.setConfigService(configService);
Transaction.clearTransaction();
Transaction transaction = Transaction.getTransaction(true);
ClassMethodSignature classMethodSignature = new ClassMethodSignature("className", "methodName", "methodDesc");
MetricNameFormat metricNameFormat = new DefaultMetricNameFormat(classMethodSignature, "", "something");
CatTestCustomTracer tracer = new CatTestCustomTracer(transaction, classMethodSignature, null, metricNameFormat, TracerFlags.DISPATCHER | TracerFlags.GENERATE_SCOPED_METRIC);
transaction.getTransactionActivity().tracerStarted(tracer);
cps = transaction.getCrossProcessState();
return tracer;
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class AgentHelper method mockAgentConfig.
public static AgentConfig mockAgentConfig() {
ServiceManager serviceManger = Mockito.spy(ServiceFactory.getServiceManager());
ConfigService configService = Mockito.spy(serviceManger.getConfigService());
Mockito.doReturn(configService).when(serviceManger).getConfigService();
ServiceFactory.setServiceManager(serviceManger);
AgentConfig agentConfig = Mockito.spy(configService.getDefaultAgentConfig());
Mockito.doReturn(agentConfig).when(configService).getDefaultAgentConfig();
Mockito.doReturn(agentConfig).when(configService).getAgentConfig(anyString());
return agentConfig;
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class AgentHelper method mockAgentConfig.
public static AgentConfig mockAgentConfig(TransactionTracerConfig transactionTracerConfig) {
ServiceManager serviceManger = Mockito.spy(ServiceFactory.getServiceManager());
ConfigService configService = Mockito.spy(serviceManger.getConfigService());
Mockito.doReturn(configService).when(serviceManger).getConfigService();
ServiceFactory.setServiceManager(serviceManger);
AgentConfig agentConfig = Mockito.spy(configService.getDefaultAgentConfig());
Mockito.doReturn(agentConfig).when(configService).getDefaultAgentConfig();
Mockito.doReturn(agentConfig).when(configService).getAgentConfig(anyString());
Mockito.doReturn(transactionTracerConfig).when(configService).getTransactionTracerConfig(anyString());
return agentConfig;
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class DatabaseServiceTest 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);
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);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
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;
}
Aggregations