use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class RandomTransactionSamplerTest method createServiceManager.
private void createServiceManager() throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
Map<String, Object> configMap = createConfigMap();
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
serviceManager.setConfigService(configService);
DatabaseService dbService = new DatabaseService();
serviceManager.setDatabaseService(dbService);
TransactionTraceService ttService = new TransactionTraceService();
serviceManager.setTransactionTraceService(ttService);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class TransactionSegmentTest method testTransactionSegmentFilter.
@Test
public void testTransactionSegmentFilter() throws Exception {
// Exclude red, yellow, and http.url attributes
Map<String, Object> transactionSegmentsConfig = new HashMap<>();
Map<String, Object> attributesMap = new HashMap<>();
transactionSegmentsConfig.put("attributes", attributesMap);
attributesMap.put("enabled", true);
attributesMap.put("exclude", "red,yellow,http.url");
MockServiceManager manager = setupServiceManager(transactionSegmentsConfig);
Map<String, Object> tracerAttributes = new HashMap<>();
tracerAttributes.put("red", "red");
tracerAttributes.put("yellow", "yellow");
tracerAttributes.put("green", "green");
TransactionSegment segment = createSegment(manager, tracerAttributes);
JSONArray array = (JSONArray) AgentHelper.serializeJSON(segment);
Map<String, Object> attributes = (Map<String, Object>) array.get(3);
Assert.assertEquals("green", attributes.get("green"));
// Red and yellow should be filtered out
Assert.assertNull(attributes.get("red"));
Assert.assertNull(attributes.get("yellow"));
Assert.assertNull(attributes.get("http.url"));
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class TransactionTraceBucketTest method createServiceManager.
private void createServiceManager(Map<String, Object> configMap) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
AgentConfig agentConfig = createConfig(configMap);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, configMap);
serviceManager.setConfigService(configService);
DatabaseService dbService = new DatabaseService();
serviceManager.setDatabaseService(dbService);
TransactionTraceService ttService = new TransactionTraceService();
serviceManager.setTransactionTraceService(ttService);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ProfileTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
Map<String, Object> map = new HashMap<>();
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(map);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, map);
serviceManager.setConfigService(configService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
threadNameNormalizer = new ThreadNameNormalizer(agentConfig, threadService);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class JmxObjectFactoryTest method setUpAgent.
@Before
public void setUpAgent() {
serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
AgentConfig config = AgentConfigImpl.createAgentConfig(Collections.<String, Object>emptyMap());
ConfigService configService = ConfigServiceFactory.createConfigService(config, Collections.<String, Object>emptyMap());
serviceManager.setConfigService(configService);
serviceManager.setExtensionService(new ExtensionService(configService, ExtensionsLoadedListener.NOOP));
}
Aggregations