Search in sources :

Example 11 with Stats

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

the class DistributedTraceCrossAgentTest method assertExpectedMetrics.

private void assertExpectedMetrics(ArrayList metrics, TransactionStats transactionStats) {
    Assert.assertNotNull(transactionStats);
    for (Object metric : metrics) {
        ArrayList expectedStats = (ArrayList) metric;
        String expectedMetricName = (String) expectedStats.get(0);
        Long expectedMetricCount = (Long) ((JSONArray) metric).get(1);
        final String message = String.format("Expected call count %d for: %s", expectedMetricCount, expectedMetricName);
        if (expectedMetricName.startsWith("Supportability") || expectedMetricName.startsWith("ErrorsByCaller")) {
            Stats actualStat = transactionStats.getUnscopedStats().getStats(expectedMetricName);
            Assert.assertEquals(message, expectedMetricCount.intValue(), actualStat.getCallCount());
        } else {
            ResponseTimeStats actualStat = transactionStats.getUnscopedStats().getOrCreateResponseTimeStats(expectedMetricName);
            Assert.assertEquals(message, expectedMetricCount.intValue(), actualStat.getCallCount());
        }
    }
}
Also used : ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) ArrayList(java.util.ArrayList) TransactionStats(com.newrelic.agent.stats.TransactionStats) ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) Stats(com.newrelic.agent.stats.Stats) JSONObject(org.json.simple.JSONObject)

Aggregations

Stats (com.newrelic.agent.stats.Stats)11 Test (org.junit.Test)6 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)4 StatsEngine (com.newrelic.agent.stats.StatsEngine)4 Trace (com.newrelic.api.agent.Trace)4 TransactionStats (com.newrelic.agent.stats.TransactionStats)3 ArrayList (java.util.ArrayList)3 StatsEngineImpl (com.newrelic.agent.stats.StatsEngineImpl)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Transaction (org.hibernate.Transaction)2 Session (org.hibernate.classic.Session)2 TransactionData (com.newrelic.agent.TransactionData)1 TransactionListener (com.newrelic.agent.TransactionListener)1 AgentConfigFactoryTest (com.newrelic.agent.config.AgentConfigFactoryTest)1 Environment (com.newrelic.agent.environment.Environment)1 AbstractStats (com.newrelic.agent.stats.AbstractStats)1 SimpleStatsEngine (com.newrelic.agent.stats.SimpleStatsEngine)1 StatsService (com.newrelic.agent.stats.StatsService)1 Tracer (com.newrelic.agent.tracers.Tracer)1 List (java.util.List)1