use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class BrowserConfigTest method testRumDisabled.
@Test
public void testRumDisabled() throws Exception {
setupManager(false, false);
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
TransactionNamePriority expectedPriority = TransactionNamePriority.FILTER_NAME;
PriorityTransactionName ptn = PriorityTransactionName.create("name", null, expectedPriority);
tx.setPriorityTransactionName(ptn);
// off
try {
Map<String, Object> beaconSettings = createBeaconSettings(false);
BrowserConfig beaconConfig = BrowserConfig.createBrowserConfig("appName", beaconSettings);
beaconConfig.getBrowserTimingHeader();
Assert.fail("An exception should have been thrown when rum is disabled");
} catch (Exception e) {
// we should go into here
}
// back on
Map<String, Object> beaconSettings = createBeaconSettings(true);
BrowserConfig beaconConfig = BrowserConfig.createBrowserConfig("appName", beaconSettings);
BrowserTransactionState bts = BrowserTransactionStateImpl.create(tx);
Assert.assertEquals(HEADER, beaconConfig.getBrowserTimingHeader());
Assert.assertTrue(beaconConfig.getBrowserTimingFooter(bts).startsWith("\n<script type=\"text/javascript\">window.NREUM||"));
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class BrowserConfigTest method testFooterNoCaptureParamsNoAgentFile.
@Test
public void testFooterNoCaptureParamsNoAgentFile() throws Exception {
setupManager(false, false);
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
TransactionNamePriority expectedPriority = TransactionNamePriority.FILTER_NAME;
PriorityTransactionName ptn = PriorityTransactionName.create("name", null, expectedPriority);
tx.setPriorityTransactionName(ptn);
tx.getUserAttributes().put("theInt", 11);
tx.getUserAttributes().put("theDouble", 11.22);
tx.getUserAttributes().put("theLong", 22L);
tx.getUserAttributes().put("theString", "abc123");
tx.getUserAttributes().put("theShort", Short.parseShort("1"));
Map<String, Object> beaconSettings = createBeaconSettingsEmtpyAgentFile(true);
BrowserConfig beaconConfig = BrowserConfig.createBrowserConfig("appName", beaconSettings);
BrowserTransactionState bts = BrowserTransactionStateImpl.create(tx);
Assert.assertEquals(HEADER, beaconConfig.getBrowserTimingHeader());
// The value looks something like this but with no line breaks:
// <script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={
// "applicationID":"45047","applicationTime":4045,"beacon":"staging-beacon-2.newrelic.com","queueTime":0,
// "licenseKey":"3969ca217b","transactionName":"DxIJAw==","agent":"",
// "errorBeacon":"staging-jserror.newrelic.com"}</script>
String value = beaconConfig.getBrowserTimingFooter(bts);
List<String> matched = new ArrayList<>(15);
checkFooter(value, matched);
List<String> expectedFooterProperties = Arrays.asList(EXPECTED_FOOTER_PROPERTIES_EMPTY_AGENT);
checkStrings(value, expectedFooterProperties, matched);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class BrowserConfigTest method testFooterCaptureAgnetAndUserAttsOneAndSsl.
@Test
public void testFooterCaptureAgnetAndUserAttsOneAndSsl() throws Exception {
setupManager(true, true);
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer tracer = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(tracer);
TransactionNamePriority expectedPriority = TransactionNamePriority.FILTER_NAME;
PriorityTransactionName ptn = PriorityTransactionName.create("name", null, expectedPriority);
tx.setPriorityTransactionName(ptn);
tx.getUserAttributes().put("product", "daProduct");
tx.getAgentAttributes().put("jvmbb.thread", "123abc");
// this one will get ignored
tx.getAgentAttributes().put("jvm.thread", "123abc");
Map<String, Object> beaconSettings = createBeaconSettings(true);
BrowserConfig beaconConfig = BrowserConfig.createBrowserConfig("appName", beaconSettings);
BrowserTransactionState bts = BrowserTransactionStateImpl.create(tx);
Assert.assertEquals(HEADER, beaconConfig.getBrowserTimingHeader());
String value = beaconConfig.getBrowserTimingFooter(bts);
List<String> matched = new ArrayList<>(15);
checkFooter(value, matched);
ArrayList<String> expectedFooterProperties = new ArrayList<>();
expectedFooterProperties.addAll(Arrays.asList(EXPECTED_FOOTER_PROPERTIES));
expectedFooterProperties.add("\"sslForHttp\":true");
String[] USER_ATTRIBUTES = { "\"product\":\"daProduct\"" };
List<String> expectedUserAttributes = Arrays.asList(USER_ATTRIBUTES);
String[] AGENT_ATTRIBUTES = { "\"jvmbb.thread\":\"123abc\"" };
List<String> expectedAgentAttributes = Arrays.asList(AGENT_ATTRIBUTES);
checkStringsAndUserParams(value, expectedFooterProperties, expectedUserAttributes, expectedAgentAttributes, matched);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class MessagingUtilTest method createDispatcherTracer.
// Create a Tracer for tests that require one.
private BasicRequestRootTracer createDispatcherTracer() {
Transaction tx = Transaction.getTransaction();
tx.setApplicationName(ApplicationNamePriority.REQUEST_ATTRIBUTE, APP_NAME);
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 AbstractPriorityTransactionNamingPolicyTest method startWebTransaction.
private void startWebTransaction() throws Exception {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
httpRequest.setRequestURI("");
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);
}
Aggregations