Search in sources :

Example 56 with StatsEngine

use of com.newrelic.agent.stats.StatsEngine in project newrelic-java-agent by newrelic.

the class IgnoreErrorsTest method ignoreClassMessagesFallbackOverride.

@Test
public void ignoreClassMessagesFallbackOverride() throws Exception {
    EnvironmentHolder holder = setupEnvironemntHolder("ignore_class_messages_fallback_test");
    try {
        try {
            // Doesn't matter what the message is, it will be ignored
            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();
    }
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) TransactionData(com.newrelic.agent.TransactionData) StatsEngine(com.newrelic.agent.stats.StatsEngine) Test(org.junit.Test)

Example 57 with StatsEngine

use of com.newrelic.agent.stats.StatsEngine 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 58 with StatsEngine

use of com.newrelic.agent.stats.StatsEngine 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 59 with StatsEngine

use of com.newrelic.agent.stats.StatsEngine in project newrelic-java-agent by newrelic.

the class IgnoreErrorsTest method ignoreErrorNoTransaction.

@Test
public void ignoreErrorNoTransaction() throws Exception {
    EnvironmentHolder holder = setupEnvironemntHolder("ignore_error_test");
    try {
        try {
            throwExceptionNoTransaction("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(0, transactionList.size());
        StatsEngine statsEngine = holder.getStatsEngine();
        assertEquals(0, statsEngine.getStats("Errors/all").getCallCount());
    } finally {
        holder.close();
    }
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) StatsEngine(com.newrelic.agent.stats.StatsEngine) Test(org.junit.Test)

Example 60 with StatsEngine

use of com.newrelic.agent.stats.StatsEngine 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)

Aggregations

StatsEngine (com.newrelic.agent.stats.StatsEngine)96 Test (org.junit.Test)78 TransactionDataList (com.newrelic.agent.TransactionDataList)36 StatsEngineImpl (com.newrelic.agent.stats.StatsEngineImpl)31 TransactionData (com.newrelic.agent.TransactionData)29 HashMap (java.util.HashMap)25 JmxMetric (com.newrelic.agent.jmx.metrics.JmxMetric)20 StatsWork (com.newrelic.agent.stats.StatsWork)8 MockRPMService (com.newrelic.agent.MockRPMService)7 ArrayList (java.util.ArrayList)6 AgentConfigFactoryTest (com.newrelic.agent.config.AgentConfigFactoryTest)5 Environment (com.newrelic.agent.environment.Environment)5 MetricName (com.newrelic.agent.metric.MetricName)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Attribute (javax.management.Attribute)5 MBeanServer (javax.management.MBeanServer)5 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)4 Stats (com.newrelic.agent.stats.Stats)4 HttpError (com.newrelic.agent.transport.HttpError)4 CountStatistic (javax.management.j2ee.statistics.CountStatistic)4