use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class NoticeErrorAttributesTest method testNoticeErrorAPIFirstCallWins.
@Test
public void testNoticeErrorAPIFirstCallWins() {
try {
Map<String, Object> settings = new HashMap<>();
settings.put("app_name", APP_NAME);
manager.setConfigService(ConfigServiceFactory.createConfigServiceUsingSettings(settings));
manager.setTransactionService(new TransactionService());
manager.setTransactionTraceService(new TransactionTraceService());
AttributesService service = new AttributesService();
manager.setAttributesService(service);
RPMServiceManager mockRPMServiceManager = manager.getRPMServiceManager();
RPMService mockRPMService = mock(RPMService.class);
ErrorService errorService = new ErrorServiceImpl(APP_NAME);
when(mockRPMServiceManager.getRPMService()).thenReturn(mockRPMService);
when(mockRPMService.getErrorService()).thenReturn(errorService);
Transaction t = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
t.getTransactionActivity().tracerStarted(tracer);
NewRelicApiImplementation impl = new NewRelicApiImplementation();
Map<String, String> atts = new HashMap<>();
atts.put("test.foo", "1");
impl.noticeError("hello", atts);
Map<String, String> atts2 = new HashMap<>();
atts.put("test.bar", "2");
impl.noticeError("hello", atts2);
Set<String> expected = Sets.newHashSet("test.foo");
verifyOutput(t.getErrorAttributes(), expected);
} finally {
Transaction.clearTransaction();
}
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class BrowserConfigTest method setupManager.
public void setupManager(boolean captureParams, boolean setSslForHttpToTrue) {
MockServiceManager manager = new MockServiceManager();
ServiceFactory.setServiceManager(manager);
Map<String, Object> params = new HashMap<>();
if (captureParams || setSslForHttpToTrue) {
Map<String, Object> bProps = new HashMap<>();
params.put("browser_monitoring", bProps);
if (captureParams) {
Map<String, Object> baProps = new HashMap<>();
bProps.put("attributes", baProps);
baProps.put("enabled", Boolean.TRUE);
}
if (setSslForHttpToTrue) {
bProps.put("ssl_for_http", Boolean.TRUE);
}
}
params.put("license_key", LICENSE_KEY);
ImmutableMap<String, Object> distributedTracingSettings = ImmutableMap.<String, Object>builder().put(DistributedTracingConfig.ENABLED, Boolean.FALSE).build();
params.put(AgentConfigImpl.DISTRIBUTED_TRACING, distributedTracingSettings);
manager.setConfigService(ConfigServiceFactory.createConfigServiceUsingSettings(params));
manager.setTransactionService(new TransactionService());
manager.setTransactionTraceService(new TransactionTraceService());
MockRPMServiceManager rpmServiceMgr = new MockRPMServiceManager();
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setEverConnected(true);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceMgr.setRPMService(rpmService);
manager.setRPMServiceManager(rpmServiceMgr);
AttributesService attService = new AttributesService();
manager.setAttributesService(attService);
ServiceFactory.setServiceManager(manager);
Transaction.clearTransaction();
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class CommandParserTest method createServiceManager.
private MockServiceManager createServiceManager(Map<String, Object> config) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(config), config);
serviceManager.setConfigService(configService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
RPMConnectionService rpmConnectionService = new RPMConnectionServiceImpl();
serviceManager.setRPMConnectionService(rpmConnectionService);
ProfilerService profilerService = new ProfilerService();
serviceManager.setProfilerService(profilerService);
EnvironmentService envService = new EnvironmentServiceImpl();
serviceManager.setEnvironmentService(envService);
HarvestService harvestService = new HarvestServiceImpl();
serviceManager.setHarvestService(harvestService);
return serviceManager;
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class CommandParserThreadProfilerTest method createServiceManager.
private MockServiceManager createServiceManager(Map<String, Object> config) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(config), config);
serviceManager.setConfigService(configService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
RPMConnectionService rpmConnectionService = new RPMConnectionServiceImpl();
serviceManager.setRPMConnectionService(rpmConnectionService);
ProfilerService profilerService = new ProfilerService();
serviceManager.setProfilerService(profilerService);
EnvironmentService envService = new EnvironmentServiceImpl();
serviceManager.setEnvironmentService(envService);
HarvestService harvestService = new HarvestServiceImpl();
serviceManager.setHarvestService(harvestService);
return serviceManager;
}
use of com.newrelic.agent.TransactionService in project newrelic-java-agent by newrelic.
the class HighSecurityAttributesTest method testHighSecurityOnWithOtherDefaultsThroughNoticeErrorAPIMessage.
@Test
public void testHighSecurityOnWithOtherDefaultsThroughNoticeErrorAPIMessage() {
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);
RPMServiceManager mockRPMServiceManager = manager.getRPMServiceManager();
RPMService mockRPMService = mock(RPMService.class);
ErrorService errorService = new ErrorServiceImpl(APP_NAME);
when(mockRPMServiceManager.getRPMService()).thenReturn(mockRPMService);
when(mockRPMService.getErrorService()).thenReturn(errorService);
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("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();
}
}
Aggregations