use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class AgentTest method transactionTraceDisabled.
@Test
public void transactionTraceDisabled() throws Exception {
try {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
AgentHelper.invokeServlet(new TestServlet(), "", "App", "/foo/bar");
synchronized (this) {
wait(1000);
}
Assert.assertEquals(2, txList.size());
TransactionData transactionData = txList.get(1);
Tracer dispatcherTracer = transactionData.getRootTracer();
Assert.assertTrue(dispatcherTracer.getDuration() > dispatcherTracer.getExclusiveDuration());
} finally {
}
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testLargeCompletableFuture.
@Test
public void testLargeCompletableFuture() throws Exception {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Integer> future = doLargeCompletableFuture();
Integer result = future.get();
assertNotNull(result);
assertEquals(9, (int) result);
// Give the transaction time to finish
txs.waitFor(1, 5000);
assertEquals(1, txs.size());
TransactionData txData = txs.get(0);
Map<String, Object> userAttributes = txData.getUserAttributes();
assertNotNull(userAttributes);
assertEquals(1, userAttributes.size());
assertEquals(9, userAttributes.get("max"));
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testAcceptEitherAsync.
@Test
public void testAcceptEitherAsync() {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
acceptEitherAsync();
pause(500);
AgentHelper.verifyMetrics(AgentHelper.getMetrics(), TRANSACTION_NAME);
TransactionData transactionData = txs.get(0);
Map<String, Object> userAttributes = transactionData.getUserAttributes();
assertTrue(userAttributes.containsKey("result"));
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testApplyEither.
@Test
public void testApplyEither() throws Exception {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Integer> future = doApplyEither();
Integer result = future.get();
assertNotNull(result);
assertEquals(4, (int) result);
// Give the transaction time to finish
txs.waitFor(1, 5000);
assertEquals(1, txs.size());
TransactionData txData = txs.get(0);
Map<String, Object> userAttributes = txData.getUserAttributes();
assertNotNull(userAttributes);
assertEquals(3, userAttributes.size());
assertEquals(1, userAttributes.get("f1"));
assertEquals(2, userAttributes.get("f2"));
assertEquals(4, userAttributes.get("f3"));
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testNoComplete.
@Test
public void testNoComplete() throws InterruptedException, ExecutionException {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Object> future = composeCompletable();
// Give the transaction time to finish
txs.waitFor(1, 5000);
assertEquals(1, txs.size());
TransactionData txData = txs.get(0);
Map<String, Object> userAttributes = txData.getUserAttributes();
assertNotNull(userAttributes);
assertEquals(0, userAttributes.size());
}
Aggregations