Search in sources :

Example 11 with MockRPMServiceManager

use of com.newrelic.agent.MockRPMServiceManager in project newrelic-java-agent by newrelic.

the class DistributedTracingApiTest method setup.

@Before
public void setup() throws Exception {
    serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    setupConfig(false);
    serviceManager.setTransactionService(new TransactionService());
    serviceManager.setAttributesService(new AttributesService());
    AgentBridge.agent = new AgentImpl(Agent.LOG);
    serviceManager.setRPMServiceManager(new MockRPMServiceManager());
    ServiceFactory.getServiceManager().start();
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    ServiceFactory.getTransactionService().addTransactionListener(distributedTraceService);
    SpanEventsServiceImpl spanEventsService = SpanEventsServiceImpl.builder().agentConfig(agentConfig).build();
    serviceManager.setDistributedTraceService(distributedTraceService);
    serviceManager.setSpansEventService(spanEventsService);
    Map<String, Object> connectInfo = ImmutableMap.<String, Object>of(ACCOUNT_ID, "33", TRUSTED_ACCOUNT_KEY, "33", PRIMARY_APPLICATION_ID, "2827902");
    AgentConfig agentConfig = AgentHelper.createAgentConfig(true, Collections.<String, Object>emptyMap(), connectInfo);
    distributedTraceService.connected(null, agentConfig);
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) TransactionService(com.newrelic.agent.TransactionService) SpanEventsServiceImpl(com.newrelic.agent.service.analytics.SpanEventsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) AgentImpl(com.newrelic.agent.AgentImpl) Before(org.junit.Before)

Example 12 with MockRPMServiceManager

use of com.newrelic.agent.MockRPMServiceManager in project newrelic-java-agent by newrelic.

the class ServletUtilsTest method createServiceManager.

private static void createServiceManager(Map<String, Object> configMap) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
    serviceManager.setConfigService(configService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
    serviceManager.setSqlTraceService(sqlTraceService);
    AttributesService attService = new AttributesService();
    serviceManager.setAttributesService(attService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
}
Also used : ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService)

Example 13 with MockRPMServiceManager

use of com.newrelic.agent.MockRPMServiceManager in project newrelic-java-agent by newrelic.

the class SlowQueryInfoTest method setupServiceManager.

private void setupServiceManager(Map<String, Object> settings) {
    MockServiceManager serviceManager = new MockServiceManager();
    settings.put("app_name", "Unit Test");
    serviceManager.setConfigService(ConfigServiceFactory.createConfigServiceUsingSettings(settings));
    serviceManager.setTransactionTraceService(Mockito.mock(TransactionTraceService.class));
    serviceManager.setTransactionService(Mockito.mock(TransactionService.class));
    serviceManager.setTransactionEventsService(Mockito.mock(TransactionEventsService.class));
    serviceManager.setHarvestService(Mockito.mock(HarvestService.class));
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.setDistributedTraceService(new DistributedTraceServiceImpl());
    serviceManager.setAttributesService(new AttributesService());
    serviceManager.setRPMServiceManager(new MockRPMServiceManager());
}
Also used : TransactionService(com.newrelic.agent.TransactionService) HarvestService(com.newrelic.agent.HarvestService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService)

Example 14 with MockRPMServiceManager

use of com.newrelic.agent.MockRPMServiceManager in project newrelic-java-agent by newrelic.

the class KeyTransactionTraceSamplerTest method createServiceManager.

private void createServiceManager(Map<String, Object> configMap) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
    serviceManager.setConfigService(configService);
    DatabaseService dbService = new DatabaseService();
    serviceManager.setDatabaseService(dbService);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmService.setIsConnected(true);
    rpmServiceManager.setRPMService(rpmService);
    CommandParser commandParser = new CommandParser();
    serviceManager.setCommandParser(commandParser);
    AttributesService attService = new AttributesService();
    serviceManager.setAttributesService(attService);
    TransactionTraceService ttService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(ttService);
    ttService.start();
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) DatabaseService(com.newrelic.agent.database.DatabaseService) MockRPMService(com.newrelic.agent.MockRPMService) CommandParser(com.newrelic.agent.commands.CommandParser)

Example 15 with MockRPMServiceManager

use of com.newrelic.agent.MockRPMServiceManager in project newrelic-java-agent by newrelic.

the class NormalizedTransactionTrace method setUrlRules.

private String setUrlRules(JSONArray rules) {
    MockRPMServiceManager rpmServiceManager = (MockRPMServiceManager) ServiceFactory.getRPMServiceManager();
    List<ConnectionListener> connectionListeners = rpmServiceManager.getConnectionListeners();
    ConnectionListener connectionListener = connectionListeners.get(0);
    MockRPMService rpmService = (MockRPMService) rpmServiceManager.getRPMService();
    String appName = rpmService.getApplicationName();
    Map<String, Object> data = new HashMap<>();
    data.put(NormalizationRuleConfig.METRIC_NAME_RULES_KEY, rules);
    connectionListener.connected(rpmService, AgentConfigImpl.createAgentConfig(data));
    return appName;
}
Also used : HashMap(java.util.HashMap) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) JSONObject(org.json.simple.JSONObject) ConnectionListener(com.newrelic.agent.ConnectionListener) MockRPMService(com.newrelic.agent.MockRPMService)

Aggregations

MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)57 MockServiceManager (com.newrelic.agent.MockServiceManager)46 MockRPMService (com.newrelic.agent.MockRPMService)44 TransactionService (com.newrelic.agent.TransactionService)31 ConfigService (com.newrelic.agent.config.ConfigService)29 MockHarvestService (com.newrelic.agent.MockHarvestService)25 HarvestService (com.newrelic.agent.HarvestService)24 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)24 ThreadService (com.newrelic.agent.ThreadService)23 AttributesService (com.newrelic.agent.attributes.AttributesService)22 MockCoreService (com.newrelic.agent.MockCoreService)19 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)17 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)16 HashMap (java.util.HashMap)16 Test (org.junit.Test)16 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)15 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)15 AgentConfig (com.newrelic.agent.config.AgentConfig)14 StatsService (com.newrelic.agent.stats.StatsService)14 DistributedTraceServiceImpl (com.newrelic.agent.tracing.DistributedTraceServiceImpl)9