use of com.newrelic.api.agent.NewRelicApiImplementation in project newrelic-java-agent by newrelic.
the class HighSecurityAttributesTest method testHighSecurityOnWithOtherDefaultsThroughAPI.
@Test
public void testHighSecurityOnWithOtherDefaultsThroughAPI() {
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());
Transaction t = Transaction.getTransaction();
NewRelicApiImplementation impl = new NewRelicApiImplementation();
impl.addCustomParameter("abc.thread", "1");
impl.addCustomParameter("request.many", "1");
impl.addCustomParameter("message.many", "1");
impl.addCustomParameter("request.parameters.foo", "1");
impl.addCustomParameter("request.parameters.bar", "1");
impl.addCustomParameter("message.parameters.foo", "1");
impl.addCustomParameter("message.parameters.bar", "1");
// user attributes should be off
Set<String> expected = new HashSet<>();
AttributesService service = new AttributesService();
verifyOutput(service.filterErrorEventAttributes(APP_NAME, t.getUserAttributes()), expected);
verifyOutput(service.filterTransactionEventAttributes(APP_NAME, t.getUserAttributes()), expected);
verifyOutput(service.filterTransactionTraceAttributes(APP_NAME, t.getUserAttributes()), expected);
verifyOutput(service.filterBrowserAttributes(APP_NAME, t.getUserAttributes()), expected);
verifyOutput(service.filterSpanEventAttributes(APP_NAME, t.getUserAttributes()), expected);
verifyOutput(service.filterTransactionSegmentAttributes(APP_NAME, t.getUserAttributes()), expected);
} finally {
Transaction.clearTransaction();
}
}
use of com.newrelic.api.agent.NewRelicApiImplementation in project newrelic-java-agent by newrelic.
the class NoticeErrorAttributesTest method testStringifiesAndTruncates.
@Test
public void testStringifiesAndTruncates() {
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, Object> atts = new HashMap<>();
atts.put("test.foo", new Object() {
@Override
public String toString() {
String base = "a";
for (int i = 0; i < 10; i++) {
base += base;
}
return base;
}
});
impl.noticeError("hello", atts);
Assert.assertEquals(t.getErrorAttributes().keySet(), Sets.newHashSet("test.foo"));
Assert.assertEquals(255, ((String) t.getErrorAttributes().get("test.foo")).length());
Assert.assertNotEquals(255, atts.get("test.foo").toString().length());
} finally {
Transaction.clearTransaction();
}
}
Aggregations