use of com.newrelic.agent.bridge.TransactionNamePriority 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.bridge.TransactionNamePriority 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.bridge.TransactionNamePriority 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.bridge.TransactionNamePriority 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.bridge.TransactionNamePriority 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);
}
Aggregations