Search in sources :

Example 21 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName 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);
}
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) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 22 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName 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);
}
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) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 23 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName in project newrelic-java-agent by newrelic.

the class PostDelegatingClassLoaderTest method getTransaction.

private static Transaction getTransaction() {
    if (agentEnabled) {
        return Transaction.getTransaction();
    }
    Transaction tx = Mockito.mock(Transaction.class);
    PriorityTransactionName name = Mockito.mock(PriorityTransactionName.class);
    Mockito.when(tx.getPriorityTransactionName()).thenReturn(name);
    Mockito.when(name.getPartialName()).thenReturn("/Filter/Zoidberg");
    return tx;
}
Also used : Transaction(com.newrelic.agent.Transaction) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName)

Example 24 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName 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 25 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName 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)

Aggregations

PriorityTransactionName (com.newrelic.agent.transaction.PriorityTransactionName)26 Test (org.junit.Test)21 Transaction (com.newrelic.agent.Transaction)19 TransactionNamePriority (com.newrelic.agent.bridge.TransactionNamePriority)14 BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)14 ArrayList (java.util.ArrayList)7 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)5 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)3 TransactionStats (com.newrelic.agent.stats.TransactionStats)3 AgentConfig (com.newrelic.agent.config.AgentConfig)2 SimpleStatsEngine (com.newrelic.agent.stats.SimpleStatsEngine)2 DistributedTracePayloadImpl (com.newrelic.agent.tracing.DistributedTracePayloadImpl)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 NewRelicIgnoreTransaction (test.newrelic.test.agent.TraceAnnotationTest.NewRelicIgnoreTransaction)2 TransactionData (com.newrelic.agent.TransactionData)1 TransactionListener (com.newrelic.agent.TransactionListener)1 BrowserMonitoringConfig (com.newrelic.agent.config.BrowserMonitoringConfig)1 DistributedTracingConfig (com.newrelic.agent.config.DistributedTracingConfig)1 Dispatcher (com.newrelic.agent.dispatchers.Dispatcher)1