use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class IgnoreErrorsTest method ignoreClassesFallback.
@Test
public void ignoreClassesFallback() throws Exception {
EnvironmentHolder holder = setupEnvironemntHolder("ignore_classes_fallback_test");
try {
try {
throwException(new IgnoredError("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(0, 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 ignoreSuperclassMessages.
@Test
public void ignoreSuperclassMessages() throws Exception {
EnvironmentHolder holder = setupEnvironemntHolder("ignore_superclass_messages_test");
try {
try {
throwException(new IgnoredError("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();
// yml is configured to ignore the superclass Exception, shouldn't apply to subclass IgnoredError
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 ApiTest method setRequestAndResponseFirstWins.
@Test
public void setRequestAndResponseFirstWins() throws Exception {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("otherRootTracer"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
Request firstRequest = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "firstWins", "", ""));
Response firstResponse = new FirstResponse(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(firstRequest, firstResponse);
Request secondRequest = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "thisIsABug", "", ""));
Response secondResponse = new SecondResponse(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(secondRequest, secondResponse);
tracer.finish(0, null);
Assert.assertEquals(firstRequest.getRequestURI(), tx.getDispatcher().getUri());
Assert.assertEquals(firstResponse.getStatus(), ((WebRequestDispatcher) tx.getDispatcher()).getStatus());
String name = tx.getPriorityTransactionName().getName();
Assert.assertNotEquals("WebTransaction/Uri/thisIsABug", name);
Assert.assertEquals("WebTransaction/Uri/firstWins", name);
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class ApiTest method setRequestAndResponseNullRequestResponse.
@Test
public void setRequestAndResponseNullRequestResponse() {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("otherRootTracer"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
NewRelic.setRequestAndResponse(null, null);
Assert.assertFalse(tx.isWebRequestSet());
Assert.assertFalse(tx.isWebResponseSet());
tracer.finish(0, null);
Assert.assertTrue(tx.isWebTransaction());
}
use of com.newrelic.agent.TransactionDataList in project newrelic-java-agent by newrelic.
the class ApiTest method testSetRequestAndResponse.
@Test
public void testSetRequestAndResponse() {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("blah"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(request, response);
tracer.finish(0, null);
Assert.assertEquals(1, txList.size());
Assert.assertEquals("/mytest", txList.get(0).getRequestUri(AgentConfigImpl.ATTRIBUTES));
TransactionStats stats = apiTestHelper.tranStats;
ResponseTimeStats dispatcherStats = stats.getUnscopedStats().getOrCreateResponseTimeStats("HttpDispatcher");
Assert.assertEquals(1, dispatcherStats.getCallCount());
Assert.assertEquals(1, stats.getUnscopedStats().getOrCreateResponseTimeStats("WebTransaction/Uri/mytest").getCallCount());
Assert.assertEquals(1, stats.getUnscopedStats().getApdexStats("Apdex/Uri/mytest").getApdexSatisfying());
Assert.assertEquals(1, stats.getUnscopedStats().getApdexStats("Apdex").getApdexSatisfying());
Assert.assertEquals(1, stats.getUnscopedStats().getOrCreateResponseTimeStats(MetricNames.WEB_TRANSACTION).getCallCount());
Assert.assertEquals(0, stats.getUnscopedStats().getOrCreateResponseTimeStats(MetricNames.OTHER_TRANSACTION_ALL).getCallCount());
}
Aggregations