use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testNoticeErrorThrowableParamsInsideTransaction.
@Test
public void testNoticeErrorThrowableParamsInsideTransaction() {
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
NewRelic.noticeError("boom", new HashMap<String, String>());
try {
Class<? extends Transaction> c = tx.getClass();
Method m = c.getDeclaredMethod("getThrowable");
TransactionThrowable transactionThrowable = (TransactionThrowable) m.invoke(tx);
Assert.assertEquals("boom", transactionThrowable.throwable.getMessage());
} catch (SecurityException | InvocationTargetException | IllegalArgumentException | NoSuchMethodException | IllegalAccessException e) {
}
tx.getTransactionActivity().tracerFinished(tracer, 0);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testGetBrowserTimingShortFooterForIgnoredTransaction.
@Test
public void testGetBrowserTimingShortFooterForIgnoredTransaction() throws Exception {
ApiTestHelper.mockOutServiceManager();
Transaction tx = Transaction.getTransaction();
TransactionNamePriority expectedPriority = TransactionNamePriority.FILTER_NAME;
PriorityTransactionName ptn = PriorityTransactionName.create("name", null, expectedPriority);
tx.setPriorityTransactionName(ptn);
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
tx.setIgnore(true);
NewRelic.getBrowserTimingHeader();
String browserTimingFooter = NewRelic.getBrowserTimingFooter();
Assert.assertEquals("Incorrect short header", "", browserTimingFooter);
tx.getTransactionActivity().tracerFinished(tracer, 0);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testNoticeErrorWithParamsKeyTooLarge.
@Test
public void testNoticeErrorWithParamsKeyTooLarge() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
try {
tx.getTransactionActivity().tracerStarted(tracer);
Map<String, String> atts = new HashMap<>();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 258; i++) {
sb.append("A");
}
atts.put(sb.toString(), "two");
atts.put("three", "four");
NewRelic.noticeError("boom", atts);
Class<? extends Transaction> c = tx.getClass();
Method m = c.getDeclaredMethod("getThrowable");
TransactionThrowable transactionThrowable = (TransactionThrowable) m.invoke(tx);
Assert.assertEquals("boom", transactionThrowable.throwable.getMessage());
Assert.assertEquals(1, tx.getErrorAttributes().size());
Assert.assertNull(tx.getErrorAttributes().get("one"));
Assert.assertEquals("four", tx.getErrorAttributes().get("three"));
} finally {
tx.getTransactionActivity().tracerFinished(tracer, 0);
}
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testGetBrowserTimingHeaderWhenRUMDisabled.
@Test
public void testGetBrowserTimingHeaderWhenRUMDisabled() throws Exception {
Map<String, Object> connectionResponse = new HashMap<>();
ApiTestHelper.mockOutServiceManager(connectionResponse);
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
String browserTimingHeader = NewRelic.getBrowserTimingHeader();
Assert.assertEquals("Incorrect header", "", browserTimingHeader);
tx.getTransactionActivity().tracerFinished(tracer, 0);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testNoticeErrorMsgNullParamsInsideTransaction.
@Test
public void testNoticeErrorMsgNullParamsInsideTransaction() {
ErrorService errorService = ServiceFactory.getRPMService().getErrorService();
errorService.getAndClearTracedErrors();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
NewRelic.noticeError("paramsAreNull", null);
try {
Class<? extends Transaction> c = tx.getClass();
Method m = c.getDeclaredMethod("getThrowable");
TransactionThrowable transactionThrowable = (TransactionThrowable) m.invoke(tx);
Assert.assertEquals("paramsAreNull", transactionThrowable.throwable.getMessage());
} catch (SecurityException | InvocationTargetException | IllegalArgumentException | NoSuchMethodException | IllegalAccessException e) {
}
tx.getTransactionActivity().tracerFinished(tracer, 0);
}
Aggregations