use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testApplyAsync.
@Test
public void testApplyAsync() throws Exception {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Integer> future = doApplyAsync();
Integer result = future.get();
assertNotNull(result);
assertEquals(2, (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(2, userAttributes.size());
assertEquals(2, userAttributes.get("b"));
assertEquals(4, userAttributes.get("f"));
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testCompletableFutureError.
@Test
public void testCompletableFutureError() throws Exception {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Integer> future = doCompletableFutureError();
Integer result = future.get();
assertNotNull(result);
assertEquals(3, (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(2, userAttributes.size());
assertEquals(1, userAttributes.get("f1"));
// f2 is not here because the "exceptionally" function will get called instead
assertEquals(3, userAttributes.get("e"));
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testAcceptBothAsync.
@Test
public void testAcceptBothAsync() {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
acceptBothAsync();
pause(500);
AgentHelper.verifyMetrics(AgentHelper.getMetrics(), TRANSACTION_NAME);
TransactionData transactionData = txs.get(0);
Map<String, Object> userAttributes = transactionData.getUserAttributes();
assertTrue(userAttributes.containsKey("three"));
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class ExpectedErrorsTest method expectedClassMessagesFallbackOverride.
@Test
public void expectedClassMessagesFallbackOverride() throws Exception {
EnvironmentHolder holder = setupEnvironemntHolder("expected_class_messages_fallback_test");
try {
try {
// Doesn't matter what the message is, it will be expected
throwException(new ExpectedError("blah"));
fail("The expected exception was not thrown");
} catch (Throwable t) {
}
// Verify the transaction was created and finished
TransactionDataList transactionList = holder.getTransactionList();
ServiceFactory.getHarvestService().harvestNow();
assertEquals(1, transactionList.size());
TransactionData td = transactionList.get(0);
assertEquals("OtherTransaction/Custom/test.newrelic.test.agent.ExpectedErrorsTest/throwException", td.getPriorityTransactionName().getName());
StatsEngine statsEngine = holder.getStatsEngine();
assertEquals(0, statsEngine.getStats("Errors/all").getCallCount());
verifyExpectedErrorSupportabilityApiCalls(statsEngine, 0, 0, 1, 2);
verifyIgnoreErrorSupportabilityApiCalls(statsEngine, 0, 0, 1);
} finally {
holder.close();
}
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class ExpectedErrorsTest method expectedStatusSoClose.
@Test
public void expectedStatusSoClose() throws Exception {
EnvironmentHolder holder = setupEnvironemntHolder("non_expected_status_code_test");
try {
reportStatusCode();
// Verify the transaction was created and finished
TransactionDataList transactionList = holder.getTransactionList();
ServiceFactory.getHarvestService().harvestNow();
assertEquals(1, transactionList.size());
TransactionData td = transactionList.get(0);
assertEquals("WebTransaction/Custom/test.newrelic.test.agent.ExpectedErrorsTest/reportStatusCode", td.getPriorityTransactionName().getName());
StatsEngine statsEngine = holder.getStatsEngine();
assertEquals(0, statsEngine.getStats("ErrorsExpected/all").getCallCount());
assertEquals(1, statsEngine.getStats("Errors/all").getCallCount());
assertEquals(1, statsEngine.getApdexStats(MetricName.create(MetricNames.APDEX)).getApdexFrustrating());
verifyExpectedErrorSupportabilityApiCalls(statsEngine, 0, 0, 0, 0);
verifyIgnoreErrorSupportabilityApiCalls(statsEngine, 0, 0, 0);
} finally {
holder.close();
}
}
Aggregations