use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class TransactionNamingTest method startWebTransaction.
private void startWebTransaction(String uri) throws Exception {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
httpRequest.setRequestURI(uri);
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
Tracer tracer = new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
tx.getTransactionActivity().tracerStarted(tracer);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class MessagingUtilTest method testAddParametersWithIgnore.
/**
* Test that setIgnore() works. This requires a Tracer.
*
* @throws Exception
* @see Transaction.setIgnore()
*/
@Test
public void testAddParametersWithIgnore() throws Exception {
Map<String, Object> configMap = createConfigMap();
createServiceManager(configMap);
Map<String, String> parms = new HashMap<>();
parms.put("hello", "world");
Transaction.clearTransaction();
BasicRequestRootTracer rootTracer = createDispatcherTracer();
Transaction.getTransaction().getTransactionActivity().tracerStarted(rootTracer);
Transaction.getTransaction().setIgnore(true);
MessagingUtil.recordParameters(Transaction.getTransaction(), parms);
Map<String, String> messageParameters = Transaction.getTransaction().getPrefixedAgentAttributes().get("message.parameters.");
assertNull(messageParameters);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class AsyncTimeoutTransactionTest method createDispatcherTracer.
// Create a Tracer for tests that require one.
private BasicRequestRootTracer createDispatcherTracer() {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
return new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class AsyncTransactionTest method createDispatcherTracer.
// Create a Tracer for tests that require one.
private BasicRequestRootTracer createDispatcherTracer(String methodName) {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), methodName, "()V");
BasicRequestRootTracer brrt = new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
tx.setDispatcher(brrt.createDispatcher());
return brrt;
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testNoticeErrorWithTooManyParams.
@Test
public void testNoticeErrorWithTooManyParams() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
try {
tx.getTransactionActivity().tracerStarted(tracer);
Map<String, String> atts = Maps.newHashMapWithExpectedSize(100);
for (int i = 0; i < 70; i++) {
atts.put("key" + i, "value");
}
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(64, tx.getErrorAttributes().size());
} finally {
tx.getTransactionActivity().tracerFinished(tracer, 0);
}
}
Aggregations