Search in sources :

Example 86 with TransactionData

use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.

the class IgnoreErrorsTest method ignoreMessagesFallbackIgnored.

@Test
public void ignoreMessagesFallbackIgnored() throws Exception {
    EnvironmentHolder holder = setupEnvironemntHolder("ignore_messages_fallback_test");
    try {
        try {
            throwException(new IgnoredError("ignore"));
            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();
    }
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) TransactionData(com.newrelic.agent.TransactionData) StatsEngine(com.newrelic.agent.stats.StatsEngine) Test(org.junit.Test)

Example 87 with TransactionData

use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.

the class IgnoreErrorsTest method nonIgnoreError.

@Test
public void nonIgnoreError() throws Exception {
    EnvironmentHolder holder = setupEnvironemntHolder("non_ignore_error_test");
    try {
        try {
            throwException("something");
            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.IgnoreErrorsTest/throwException", td.getPriorityTransactionName().getName());
        StatsEngine statsEngine = holder.getStatsEngine();
        assertEquals(1, statsEngine.getStats("Errors/all").getCallCount());
    } finally {
        holder.close();
    }
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) TransactionData(com.newrelic.agent.TransactionData) StatsEngine(com.newrelic.agent.stats.StatsEngine) Test(org.junit.Test)

Example 88 with TransactionData

use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.

the class IgnoreErrorsTest method ignoreMessagesFallback.

@Test
public void ignoreMessagesFallback() throws Exception {
    EnvironmentHolder holder = setupEnvironemntHolder("ignore_messages_fallback_test");
    try {
        try {
            throwException(new IgnoredError("message"));
            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();
    }
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) TransactionData(com.newrelic.agent.TransactionData) StatsEngine(com.newrelic.agent.stats.StatsEngine) Test(org.junit.Test)

Example 89 with TransactionData

use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.

the class IgnoreErrorsTest method ignoreInterfaceMessages.

@Test
public void ignoreInterfaceMessages() throws Exception {
    EnvironmentHolder holder = setupEnvironemntHolder("ignore_interface_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 interface IgnoredErrorInterface, shouldn't apply to implementing class IgnoredError
        assertEquals(1, statsEngine.getStats("Errors/all").getCallCount());
    } finally {
        holder.close();
    }
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) TransactionData(com.newrelic.agent.TransactionData) StatsEngine(com.newrelic.agent.stats.StatsEngine) Test(org.junit.Test)

Example 90 with TransactionData

use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.

the class IgnoreErrorsTest method ignoreErrorRightMessage.

@Test
public void ignoreErrorRightMessage() throws Exception {
    EnvironmentHolder holder = setupEnvironemntHolder("ignore_error_good_message_test");
    try {
        try {
            throwException("definitely 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(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();
    }
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) TransactionData(com.newrelic.agent.TransactionData) StatsEngine(com.newrelic.agent.stats.StatsEngine) Test(org.junit.Test)

Aggregations

TransactionData (com.newrelic.agent.TransactionData)145 Test (org.junit.Test)136 TransactionDataList (com.newrelic.agent.TransactionDataList)46 TransactionStats (com.newrelic.agent.stats.TransactionStats)40 HashMap (java.util.HashMap)34 StatsEngine (com.newrelic.agent.stats.StatsEngine)29 Tracer (com.newrelic.agent.tracers.Tracer)23 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)17 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)16 Transaction (com.newrelic.agent.Transaction)15 EventTestHelper.generateTransactionData (com.newrelic.agent.service.analytics.EventTestHelper.generateTransactionData)15 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)15 JSONArray (org.json.simple.JSONArray)15 MockRPMService (com.newrelic.agent.MockRPMService)14 Map (java.util.Map)14 TransactionService (com.newrelic.agent.TransactionService)12 Java7IncompatibleTest (com.newrelic.test.marker.Java7IncompatibleTest)12 JSONObject (org.json.simple.JSONObject)12 TransactionDataTestBuilder (com.newrelic.agent.TransactionDataTestBuilder)10 SpanEvent (com.newrelic.agent.model.SpanEvent)10