Search in sources :

Example 81 with BasicRequestRootTracer

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||"));
}
Also used : Transaction(com.newrelic.agent.Transaction) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) TransactionNamePriority(com.newrelic.agent.bridge.TransactionNamePriority) Test(org.junit.Test)

Example 82 with BasicRequestRootTracer

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);
}
Also used : Transaction(com.newrelic.agent.Transaction) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName) ArrayList(java.util.ArrayList) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) TransactionNamePriority(com.newrelic.agent.bridge.TransactionNamePriority) Test(org.junit.Test)

Example 83 with BasicRequestRootTracer

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);
}
Also used : PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName) ArrayList(java.util.ArrayList) Transaction(com.newrelic.agent.Transaction) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) TransactionNamePriority(com.newrelic.agent.bridge.TransactionNamePriority) Test(org.junit.Test)

Example 84 with BasicRequestRootTracer

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);
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Example 85 with BasicRequestRootTracer

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);
}
Also used : MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) Tracer(com.newrelic.agent.tracers.Tracer) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse)

Aggregations

BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)85 Test (org.junit.Test)67 Transaction (com.newrelic.agent.Transaction)64 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)33 HashMap (java.util.HashMap)22 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)18 MockHttpResponse (com.newrelic.agent.tracers.servlet.MockHttpResponse)16 TransactionThrowable (com.newrelic.agent.transaction.TransactionThrowable)16 Method (java.lang.reflect.Method)16 MockHttpRequest (com.newrelic.agent.tracers.servlet.MockHttpRequest)15 SegmentTest (com.newrelic.agent.transaction.SegmentTest)15 TransactionNamePriority (com.newrelic.agent.bridge.TransactionNamePriority)14 PriorityTransactionName (com.newrelic.agent.transaction.PriorityTransactionName)14 TransactionService (com.newrelic.agent.TransactionService)8 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)8 NewRelicApiImplementation (com.newrelic.api.agent.NewRelicApiImplementation)8 ArrayList (java.util.ArrayList)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 Tracer (com.newrelic.agent.tracers.Tracer)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)7