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);
}
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);
}
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;
}
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||"));
}
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);
}
Aggregations