use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testGetBrowserTimingHeaderNoBeaconConfiguration.
@Test
public void testGetBrowserTimingHeaderNoBeaconConfiguration() {
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
String browserTimingHeader = NewRelic.getBrowserTimingHeader();
Assert.assertEquals("No beacon configuration, the timing header should be empty", "", 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 testGetBrowserTimingFooterNoHeader.
@Test
public void testGetBrowserTimingFooterNoHeader() 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);
String browserTimingFooter = NewRelic.getBrowserTimingFooter();
Assert.assertEquals("Incorrect 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 testNoticeErrorWithParamsObjects.
@Test
public void testNoticeErrorWithParamsObjects() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
try {
tx.getTransactionActivity().tracerStarted(tracer);
Map<String, Object> atts = new HashMap<>();
atts.put("one", 5);
atts.put("three", 6);
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(2, tx.getErrorAttributes().size());
Assert.assertEquals(5, tx.getErrorAttributes().get("one"));
Assert.assertEquals(6, 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 testNoticeErrorInsideTransaction.
@Test
public void testNoticeErrorInsideTransaction() {
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
NewRelic.noticeError(new RuntimeException("boom"));
NewRelic.noticeError(new RuntimeException("boom2"));
try {
Class<? extends Transaction> c = tx.getClass();
Method m = c.getDeclaredMethod("getThrowable");
TransactionThrowable transactionThrowable = (TransactionThrowable) m.invoke(tx);
Assert.assertNotNull(transactionThrowable.throwable);
Assert.assertEquals("boom2", 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 testSetIgnore.
@Test
public void testSetIgnore() {
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
NewRelic.ignoreTransaction();
Assert.assertEquals(Transaction.getTransaction().isIgnore(), false);
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
Assert.assertEquals(Transaction.getTransaction().isIgnore(), false);
NewRelic.ignoreTransaction();
Assert.assertEquals(Transaction.getTransaction().isIgnore(), true);
Transaction.clearTransaction();
tx = Transaction.getTransaction();
tx.setIgnore(true);
Assert.assertEquals(Transaction.getTransaction().isIgnore(), false);
tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
Assert.assertEquals(Transaction.getTransaction().isIgnore(), false);
tx.setIgnore(true);
Assert.assertEquals(Transaction.getTransaction().isIgnore(), true);
}
Aggregations