use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testNoticeThrowableWithParamsValueTooLarge.
@Test
public void testNoticeThrowableWithParamsValueTooLarge() 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("one", sb.toString());
atts.put("three", "four");
Throwable t = new Throwable("test");
NewRelic.noticeError(t, atts);
Class<? extends Transaction> c = tx.getClass();
Method m = c.getDeclaredMethod("getThrowable");
TransactionThrowable transactionThrowable = (TransactionThrowable) m.invoke(tx);
Assert.assertEquals("test", transactionThrowable.throwable.getMessage());
Assert.assertEquals(2, tx.getErrorAttributes().size());
Assert.assertEquals(sb.substring(0, 255), 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 testGetBrowserTimingHeader.
@Test
public void testGetBrowserTimingHeader() throws Exception {
ApiTestHelper.mockOutServiceManager();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
String browserTimingHeader = NewRelic.getBrowserTimingHeader();
Assert.assertEquals("Incorrect header", ApiTestHelper.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 testNoticeErrorWithParamsValueTooLarge.
@Test
public void testNoticeErrorWithParamsValueTooLarge() 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("one", sb.toString());
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(2, tx.getErrorAttributes().size());
Assert.assertEquals(sb.substring(0, 255), 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 testNoticeErrorThrowableObjectParamsInTransaction.
@Test
public void testNoticeErrorThrowableObjectParamsInTransaction() throws Exception {
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(new RuntimeException("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 TransactionTest method recordCpuAndGCTimeNotEnabled.
@Test
public void recordCpuAndGCTimeNotEnabled() throws Exception {
Map<String, Object> configMap = createConfigMap();
configMap.put(AgentConfigImpl.THREAD_CPU_TIME_ENABLED, Boolean.FALSE);
createServiceManager(configMap);
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer rootTracer = (BasicRequestRootTracer) createDispatcherTracer(true);
tx.getTransactionActivity().tracerStarted(rootTracer);
finishTransaction(tx, rootTracer);
Long cpuTime = (Long) tx.getIntrinsicAttributes().get(AttributeNames.CPU_TIME_PARAMETER_NAME);
assertNull(cpuTime);
}
Aggregations