use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class SqlTraceServiceTest method startDispatcherTracer.
private Tracer startDispatcherTracer(String appName) throws Exception {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
Tracer requestDispatcherTracer = new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
tx.getTransactionActivity().tracerStarted(requestDispatcherTracer);
tx.setApplicationName(ApplicationNamePriority.REQUEST_ATTRIBUTE, appName);
return requestDispatcherTracer;
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testNoticeThrowableWithTooManyParams.
@Test
public void testNoticeThrowableWithTooManyParams() 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");
}
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(64, tx.getErrorAttributes().size());
} 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 testNoticeErrorNullThrowableParamsInsideTransaction.
@Test
public void testNoticeErrorNullThrowableParamsInsideTransaction() {
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
NewRelic.noticeError((String) null, new HashMap<String, String>());
try {
Class<? extends Transaction> c = tx.getClass();
Method m = c.getDeclaredMethod("getThrowable");
TransactionThrowable transactionThrowable = (TransactionThrowable) m.invoke(tx);
Assert.assertNull(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 testGetBrowserTimingFooterRUM4.
@Test
public void testGetBrowserTimingFooterRUM4() throws Exception {
Map<String, Object> connectionResponse = new HashMap<>();
connectionResponse.put(ApiTestHelper.BROWSER_KEY, "3969ca217b");
connectionResponse.put(ApiTestHelper.BROWSER_LOADER_VERSION, "248");
connectionResponse.put(ApiTestHelper.JS_AGENT_LOADER, ApiTestHelper.LOADER);
connectionResponse.put(ApiTestHelper.JS_AGENT_FILE, "js-agent.newrelic.com\nr-248.min.js");
connectionResponse.put(ApiTestHelper.BEACON, "staging-beacon-2.newrelic.com");
connectionResponse.put(ApiTestHelper.ERROR_BEACON, "staging-jserror.newrelic.com");
connectionResponse.put(ApiTestHelper.APPLICATION_ID, 100L);
ApiTestHelper.mockOutServiceManager(connectionResponse);
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
NewRelic.getBrowserTimingHeader();
String browserTimingFooter = NewRelic.getBrowserTimingFooter();
Assert.assertTrue("Incorrect footer. Was " + browserTimingFooter + " expected to start with " + getTimingFooterStart(), browserTimingFooter.startsWith(getTimingFooterStart()));
tx.getTransactionActivity().tracerFinished(tracer, 0);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testGetBrowserTimingFooterWhenRUMEnabledNotSpecified.
@Test
public void testGetBrowserTimingFooterWhenRUMEnabledNotSpecified() throws Exception {
Map<String, Object> connectionResponse = new HashMap<>();
connectionResponse.put(ApiTestHelper.BROWSER_KEY, "3969ca217b");
connectionResponse.put(ApiTestHelper.BROWSER_LOADER_VERSION, "248");
connectionResponse.put(ApiTestHelper.JS_AGENT_LOADER, ApiTestHelper.LOADER);
connectionResponse.put(ApiTestHelper.JS_AGENT_FILE, "js-agent.newrelic.com\nr-248.min.js");
connectionResponse.put(ApiTestHelper.BEACON, "staging-beacon-2.newrelic.com");
connectionResponse.put(ApiTestHelper.ERROR_BEACON, "staging-jserror.newrelic.com");
connectionResponse.put(ApiTestHelper.APPLICATION_ID, 100L);
ApiTestHelper.mockOutServiceManager(connectionResponse);
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
NewRelic.getBrowserTimingHeader();
String browserTimingFooter = NewRelic.getBrowserTimingFooter();
Assert.assertTrue("Incorrect footer. Was " + browserTimingFooter + " expected to start with " + getTimingFooterStart(), browserTimingFooter.startsWith(getTimingFooterStart()));
tx.getTransactionActivity().tracerFinished(tracer, 0);
}
Aggregations