use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class IgnoreErrorsTest method ignoreStatusSoClose.
@Test
public void ignoreStatusSoClose() throws Exception {
EnvironmentHolder holder = setupEnvironemntHolder("non_ignore_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/NormalizedUri/420/*", td.getPriorityTransactionName().getName());
StatsEngine statsEngine = holder.getStatsEngine();
assertEquals(1, statsEngine.getStats("Errors/all").getCallCount());
assertEquals(1, statsEngine.getApdexStats(MetricName.create(MetricNames.APDEX)).getApdexFrustrating());
} finally {
holder.close();
}
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class IgnoreErrorsTest method ignoreErrorWrongMessageNoTransaction.
@Test
public void ignoreErrorWrongMessageNoTransaction() throws Exception {
EnvironmentHolder holder = setupEnvironemntHolder("ignore_error_bad_message_test");
try {
try {
throwExceptionNoTransaction("pleasen be right");
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(0, transactionList.size());
StatsEngine statsEngine = holder.getStatsEngine();
assertEquals(1, statsEngine.getStats("Errors/all").getCallCount());
} finally {
holder.close();
}
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class IgnoreErrorsTest method ignoreClassMessagesFallbackNotIgnored.
@Test
public void ignoreClassMessagesFallbackNotIgnored() throws Exception {
EnvironmentHolder holder = setupEnvironemntHolder("ignore_class_messages_fallback_test");
try {
try {
// This should be allowed through
throwException(new ExpectedError("blah"));
fail("The ignored 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.IgnoreErrorsTest/throwException", td.getPriorityTransactionName().getName());
StatsEngine statsEngine = holder.getStatsEngine();
assertEquals(1, statsEngine.getStats("Errors/all").getCallCount());
} finally {
holder.close();
}
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class TraceAccessorApiTest method testAcceptPayloadGetTraceId.
@Test
public void testAcceptPayloadGetTraceId() throws Exception {
EnvironmentHolder holder = setupEnvironemntHolder("all_enabled_test");
try {
DistributedTracePayloadImpl distributedTracePayload = getDistributedTracePayload();
// We don't care about the DT payload transaction, so we will harvest and clear the tx list before continuing
harvestAndCheckTxn(holder);
TransactionDataList transactionList = holder.getTransactionList();
transactionList.clear();
startTxAcceptPayloadAndAssertTraceIdDoesNotEqualTransactionGuid(distributedTracePayload);
harvestAndCheckTxn(holder);
} finally {
holder.close();
}
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class CompletableFutureTest method testCompletableFutureAccept.
@Test
public void testCompletableFutureAccept() throws Exception {
TransactionDataList txs = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txs);
CompletableFuture<Integer> future = doCompletableFutureAccept();
Integer result = future.join();
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"));
}
Aggregations