use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method createDispatcherTracer.
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 ApiTest method testGetBrowserTimingFooterTwice.
@Test
public void testGetBrowserTimingFooterTwice() 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);
NewRelic.getBrowserTimingHeader();
String browserTimingFooter = NewRelic.getBrowserTimingFooter();
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 testNoticeErrorThrowableNullParamsInsideTransaction.
@Test
public void testNoticeErrorThrowableNullParamsInsideTransaction() {
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
ErrorService errorService = ServiceFactory.getRPMService().getErrorService();
NewRelic.noticeError("paramsAreNull", null);
// in a transaction so does not show in the error service
Assert.assertEquals("Incorrect error count", 0, errorService.getAndClearTracedErrors().size());
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);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testGetBrowserTimingFooterForIgnoredTransaction.
@Test
public void testGetBrowserTimingFooterForIgnoredTransaction() throws Exception {
ApiTestHelper.mockOutServiceManager();
Transaction tx = Transaction.getTransaction();
tx.setIgnore(true);
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 footer", "", 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 testGetBrowserTimingFooterWhenComponentBasedTransactionNamingDisabled.
@Test
public void testGetBrowserTimingFooterWhenComponentBasedTransactionNamingDisabled() 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/r-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();
System.out.println(browserTimingFooter);
List<String> matched = new ArrayList<>(15);
BrowserConfigTest.checkFooter(browserTimingFooter, matched);
String expectedObfuscatedName = Obfuscator.obfuscateNameUsingKey(tx.getPriorityTransactionName().getName(), NewRelic.getAgent().getConfig().getValue("license_key", "").substring(0, 13));
List<String> expectedFooterProperties = Arrays.asList("\"beacon\":\"staging-beacon-2.newrelic.com\"", "\"queueTime\":[0-9]+", "\"licenseKey\":\"3969ca217b\"", "\"transactionName\":\"" + expectedObfuscatedName + "\"", "\"errorBeacon\":\"staging-jserror.newrelic.com\"", "\"agent\":\"js-agent.newrelic.com\\\\/r-248.min.js\"", "\"applicationTime\":[0-9]+", "\"applicationID\":\"100\"");
BrowserConfigTest.checkStrings(browserTimingFooter, expectedFooterProperties, matched);
tx.getTransactionActivity().tracerFinished(tracer, 0);
}
Aggregations