Search in sources :

Example 71 with ConfigService

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);
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) HashMap(java.util.HashMap) JSONObject(org.json.simple.JSONObject)

Example 72 with ConfigService

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;
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) HashMap(java.util.HashMap) DefaultMetricNameFormat(com.newrelic.agent.tracers.metricname.DefaultMetricNameFormat) Matchers.anyString(org.mockito.Matchers.anyString) DefaultMetricNameFormat(com.newrelic.agent.tracers.metricname.DefaultMetricNameFormat) ClassMethodMetricNameFormat(com.newrelic.agent.tracers.metricname.ClassMethodMetricNameFormat) MetricNameFormat(com.newrelic.agent.tracers.metricname.MetricNameFormat)

Example 73 with ConfigService

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;
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) ServiceManager(com.newrelic.agent.service.ServiceManager)

Example 74 with ConfigService

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;
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) ServiceManager(com.newrelic.agent.service.ServiceManager)

Example 75 with ConfigService

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;
}
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) StatsService(com.newrelic.agent.stats.StatsService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) AgentConfig(com.newrelic.agent.config.AgentConfig) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) MockConfigService(com.newrelic.agent.MockConfigService) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockHarvestService(com.newrelic.agent.MockHarvestService) MockCoreService(com.newrelic.agent.MockCoreService) MockRPMService(com.newrelic.agent.MockRPMService)

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