use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class HighSecurityAttributesTest method testHighSecurityOnWithOtherDefaultsThroughNoticeErrorAPIThrowable.
@Test
public void testHighSecurityOnWithOtherDefaultsThroughNoticeErrorAPIThrowable() {
try {
Map<String, Object> settings = new HashMap<>();
settings.put("app_name", APP_NAME);
settings.put("high_security", Boolean.TRUE);
enableBrowser(settings);
manager.setConfigService(ConfigServiceFactory.createConfigServiceUsingSettings(settings));
manager.setTransactionService(new TransactionService());
manager.setTransactionTraceService(new TransactionTraceService());
AttributesService service = new AttributesService();
manager.setAttributesService(service);
Transaction t = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
t.getTransactionActivity().tracerStarted(tracer);
NewRelicApiImplementation impl = new NewRelicApiImplementation();
Map<String, String> atts = new HashMap<>();
atts.put("abc.thread", "1");
atts.put("request.many", "1");
atts.put("message.many", "1");
atts.put("request.parameters.foo", "1");
atts.put("request.parameters.bar", "1");
atts.put("message.parameters.foo", "1");
atts.put("message.parameters.bar", "1");
impl.noticeError(new Throwable("hello"), atts);
// user attributes should be off
Set<String> expected = new HashSet<>();
verifyOutput(service.filterErrorEventAttributes(APP_NAME, t.getErrorAttributes()), expected);
verifyOutput(service.filterTransactionEventAttributes(APP_NAME, t.getErrorAttributes()), expected);
verifyOutput(service.filterTransactionTraceAttributes(APP_NAME, t.getErrorAttributes()), expected);
verifyOutput(service.filterBrowserAttributes(APP_NAME, t.getErrorAttributes()), expected);
verifyOutput(service.filterSpanEventAttributes(APP_NAME, t.getErrorAttributes()), expected);
verifyOutput(service.filterTransactionSegmentAttributes(APP_NAME, t.getErrorAttributes()), expected);
} finally {
Transaction.clearTransaction();
}
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class TransactionTraceServiceTest 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);
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();
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class TransactionTraceTest method setUp.
private void setUp(boolean isCaptureAtts, boolean captureRequestAtts, boolean requestUri, boolean simpleCompression) throws Exception {
iAgentConfig = mock(AgentConfig.class);
TransactionTracerConfig transTracerConfig = mock(TransactionTracerConfig.class);
when(iAgentConfig.getTransactionTracerConfig()).thenReturn(transTracerConfig);
when(iAgentConfig.isSimpleCompression()).thenReturn(simpleCompression);
MockServiceManager manager = new MockServiceManager();
ServiceFactory.setServiceManager(manager);
ImmutableMap<String, Object> distributedTracingSettings = ImmutableMap.<String, Object>builder().put(DistributedTracingConfig.ENABLED, Boolean.FALSE).build();
Map<String, Object> settings = new HashMap<>();
settings.put(AgentConfigImpl.DISTRIBUTED_TRACING, distributedTracingSettings);
setConfigAttributes(settings, isCaptureAtts, captureRequestAtts, requestUri, simpleCompression);
ConfigService cService = new MockConfigService(AgentConfigImpl.createAgentConfig(settings));
manager.setConfigService(cService);
manager.setTransactionTraceService(new TransactionTraceService());
manager.setTransactionService(new TransactionService());
manager.setAttributesService(new AttributesService());
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class TransactionEventsServiceTest method setup.
private void setup(boolean enabled, boolean isAttsEnabled, int size) throws Exception {
MockServiceManager manager = new MockServiceManager();
ServiceFactory.setServiceManager(manager);
Map<String, Object> settings = new HashMap<>();
settings.put("app_name", APP_NAME);
Map<String, Object> events = new HashMap<>();
settings.put("transaction_events", events);
events.put("max_samples_stored", size);
events.put("enabled", enabled);
Map<String, Object> atts = new HashMap<>();
settings.put("attributes", atts);
atts.put("enabled", isAttsEnabled);
Map<String, Object> distributedTracing = new HashMap<>();
distributedTracing.put("enabled", true);
settings.put("distributed_tracing", distributedTracing);
Map<String, Object> spanConfig = new HashMap<>();
spanConfig.put("collect_span_events", true);
settings.put("span_events", spanConfig);
iAgentConfig = AgentConfigImpl.createAgentConfig(settings);
configService = ConfigServiceFactory.createConfigService(iAgentConfig, settings);
manager.setConfigService(configService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
manager.setTransactionTraceService(transactionTraceService);
environmentService = new EnvironmentServiceImpl();
manager.setEnvironmentService(environmentService);
AttributesService attService = new AttributesService();
manager.setAttributesService(attService);
TransactionService transactionService = new TransactionService();
manager.setTransactionService(transactionService);
StatsService statsService = new StatsServiceImpl();
manager.setStatsService(statsService);
HarvestService harvestService = new MockHarvestService();
manager.setHarvestService(harvestService);
// manager.setTransactionEventsService(new TransactionEventsService(mockDistributedTraceIntrinsics));
DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
Map<String, Object> connectInfo = new HashMap<>();
connectInfo.put(DistributedTracingConfig.ACCOUNT_ID, "1acct234");
connectInfo.put(DistributedTracingConfig.TRUSTED_ACCOUNT_KEY, "67890");
AgentConfig agentConfig = AgentHelper.createAgentConfig(true, Collections.<String, Object>emptyMap(), connectInfo);
distributedTraceService.connected(null, agentConfig);
manager.setDistributedTraceService(distributedTraceService);
rpmServiceManager = new MockRPMServiceManager();
rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmServiceManager.setRPMService(rpmService);
ErrorServiceImpl errorService = new ErrorServiceImpl(APP_NAME);
rpmService.setErrorService(errorService);
rpmServiceAppName2 = (MockRPMService) rpmServiceManager.getOrCreateRPMService(APP_NAME_2);
rpmServiceAppName2.setErrorService(new ErrorServiceImpl(APP_NAME_2));
mockDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
service = new TransactionEventsService(mockDistributedTraceIntrinsics);
manager.setTransactionEventsService(service);
manager.setRPMServiceManager(rpmServiceManager);
service.addHarvestableToService(APP_NAME);
service.doStart();
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class RumStreamParserTest method createServiceManager.
private static void createServiceManager(Map<String, Object> map) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
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);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceManager.setRPMService(rpmService);
configService.start();
serviceManager.setNormalizationService(new NormalizationServiceImpl());
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
statsService.start();
}
Aggregations