Search in sources :

Example 11 with StatsBase

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

the class TransactionAsyncStartThenLinkTest method verifyDataTwo.

private void verifyDataTwo(Activity activity, Transaction tx, TokenImpl token) {
    waitForTransaction();
    TransactionAsyncUtility.basicDataVerify(data, stats, activity, 2);
    Map<String, StatsBase> scoped = stats.getScopedStats().getStatsMap();
    ResponseTimeStats data1 = (ResponseTimeStats) scoped.get("RequestDispatcher");
    ResponseTimeStats data2 = (ResponseTimeStats) scoped.get("Java/java.lang.Object/root" + token.toString());
    Assert.assertNotNull(data1);
    Assert.assertNotNull(data2);
    Assert.assertEquals(1, data1.getCallCount());
    Assert.assertEquals(1, data2.getCallCount());
    Map<String, StatsBase> unscoped = stats.getUnscopedStats().getStatsMap();
    Assert.assertEquals(((ResponseTimeStats) unscoped.get("WebTransactionTotalTime")).getTotal(), data1.getTotal() + data2.getTotal(), .001);
}
Also used : ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) StatsBase(com.newrelic.agent.stats.StatsBase)

Example 12 with StatsBase

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

the class TransactionAsyncStartThenLinkTest method testStartAndThenLinkMultipleDiffTokens.

@Test
public void testStartAndThenLinkMultipleDiffTokens() throws InterruptedException {
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
    tx.getTransactionActivity().tracerStarted(rootTracer);
    TokenImpl token1 = (TokenImpl) tx.getToken();
    TokenImpl token2 = (TokenImpl) tx.getToken();
    StartAndThenLink activity1 = new StartAndThenLink(token1, true, false);
    activity1.start();
    activity1.join();
    StartAndThenLink activity2 = new StartAndThenLink(token2, false, true);
    activity2.start();
    activity2.join();
    rootTracer.finish(Opcodes.RETURN, 0);
    waitForTransaction();
    TransactionAsyncUtility.basicDataVerify(data, stats, activity1, 3);
    Map<String, StatsBase> scoped = stats.getScopedStats().getStatsMap();
    ResponseTimeStats data1 = (ResponseTimeStats) scoped.get("RequestDispatcher");
    ResponseTimeStats data2 = (ResponseTimeStats) scoped.get("Java/java.lang.Object/root" + token1.toString());
    ResponseTimeStats data3 = (ResponseTimeStats) scoped.get("Java/java.lang.Object/root" + token2.toString());
    Assert.assertNotNull(data1);
    Assert.assertNotNull(data2);
    Assert.assertNotNull(data3);
    Assert.assertEquals(1, data1.getCallCount());
    Assert.assertEquals(1, data2.getCallCount());
    Assert.assertEquals(1, data3.getCallCount());
    Map<String, StatsBase> unscoped = stats.getUnscopedStats().getStatsMap();
    Assert.assertEquals(((ResponseTimeStats) unscoped.get("WebTransactionTotalTime")).getTotal(), data1.getTotal() + data2.getTotal() + data3.getTotal(), .001);
}
Also used : ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) Transaction(com.newrelic.agent.Transaction) TokenImpl(com.newrelic.agent.TokenImpl) Tracer(com.newrelic.agent.tracers.Tracer) StartAndThenLink(com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink) StatsBase(com.newrelic.agent.stats.StatsBase) Test(org.junit.Test)

Example 13 with StatsBase

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

the class TransactionAsyncRootFirstTest method testStartAndThenLinkMultipleSameTokens.

@Test
public void testStartAndThenLinkMultipleSameTokens() throws InterruptedException {
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
    tx.getTransactionActivity().tracerStarted(rootTracer);
    TokenImpl token1 = (TokenImpl) tx.getToken();
    rootTracer.finish(Opcodes.RETURN, 0);
    StartAndThenLink activity1 = new StartAndThenLink(token1, false, false);
    activity1.start();
    activity1.join();
    StartAndThenLink activity2 = new StartAndThenLink(token1, true, false);
    activity2.start();
    activity2.join();
    waitForTransaction();
    TransactionAsyncUtility.basicDataVerify(data, stats, activity1, 3);
    Map<String, StatsBase> scoped = stats.getScopedStats().getStatsMap();
    ResponseTimeStats data1 = (ResponseTimeStats) scoped.get("RequestDispatcher");
    ResponseTimeStats data2 = (ResponseTimeStats) scoped.get("Java/java.lang.Object/root" + token1.toString());
    Assert.assertNotNull(data1);
    Assert.assertNotNull(data2);
    Assert.assertEquals(1, data1.getCallCount());
    Assert.assertEquals(2, data2.getCallCount());
    Map<String, StatsBase> unscoped = stats.getUnscopedStats().getStatsMap();
    Assert.assertEquals(((ResponseTimeStats) unscoped.get("WebTransactionTotalTime")).getTotal(), data1.getTotal() + data2.getTotal(), .001);
}
Also used : ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) Transaction(com.newrelic.agent.Transaction) TokenImpl(com.newrelic.agent.TokenImpl) Tracer(com.newrelic.agent.tracers.Tracer) StartAndThenLink(com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink) StatsBase(com.newrelic.agent.stats.StatsBase) Test(org.junit.Test)

Example 14 with StatsBase

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

the class TransactionAsyncRootFirstTest method verifyDataTwo.

private void verifyDataTwo(StartAndThenLink activity, Transaction tx, TokenImpl token) {
    waitForTransaction();
    TransactionAsyncUtility.basicDataVerify(data, stats, activity, 2);
    Map<String, StatsBase> scoped = stats.getScopedStats().getStatsMap();
    ResponseTimeStats data1 = (ResponseTimeStats) scoped.get("RequestDispatcher");
    ResponseTimeStats data2 = (ResponseTimeStats) scoped.get("Java/java.lang.Object/root" + token.toString());
    Assert.assertNotNull(data1);
    Assert.assertNotNull(data2);
    Assert.assertEquals(1, data1.getCallCount());
    Assert.assertEquals(1, data2.getCallCount());
    Map<String, StatsBase> unscoped = stats.getUnscopedStats().getStatsMap();
    Assert.assertEquals(((ResponseTimeStats) unscoped.get("WebTransactionTotalTime")).getTotal(), data1.getTotal() + data2.getTotal(), .001);
}
Also used : ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) StatsBase(com.newrelic.agent.stats.StatsBase)

Example 15 with StatsBase

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

the class TransactionAsyncRootFirstTest method testStartAndThenLinkMultipleSameTokensExireOrig.

@Test
public void testStartAndThenLinkMultipleSameTokensExireOrig() throws InterruptedException {
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
    tx.getTransactionActivity().tracerStarted(rootTracer);
    TokenImpl token1 = (TokenImpl) tx.getToken();
    rootTracer.finish(Opcodes.RETURN, 0);
    StartAndThenLink activity1 = new StartAndThenLink(token1, false, false);
    activity1.start();
    activity1.join();
    StartAndThenLink activity2 = new StartAndThenLink(token1, true, false);
    activity2.start();
    activity2.join();
    token1.expire();
    waitForTransaction();
    TransactionAsyncUtility.basicDataVerify(data, stats, activity1, 3);
    Map<String, StatsBase> scoped = stats.getScopedStats().getStatsMap();
    ResponseTimeStats data1 = (ResponseTimeStats) scoped.get("RequestDispatcher");
    ResponseTimeStats data2 = (ResponseTimeStats) scoped.get("Java/java.lang.Object/root" + token1.toString());
    Assert.assertNotNull(data1);
    Assert.assertNotNull(data2);
    Assert.assertEquals(1, data1.getCallCount());
    Assert.assertEquals(2, data2.getCallCount());
    Map<String, StatsBase> unscoped = stats.getUnscopedStats().getStatsMap();
    Assert.assertEquals(((ResponseTimeStats) unscoped.get("WebTransactionTotalTime")).getTotal(), data1.getTotal() + data2.getTotal(), .001);
}
Also used : ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) Transaction(com.newrelic.agent.Transaction) TokenImpl(com.newrelic.agent.TokenImpl) Tracer(com.newrelic.agent.tracers.Tracer) StartAndThenLink(com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink) StatsBase(com.newrelic.agent.stats.StatsBase) Test(org.junit.Test)

Aggregations

StatsBase (com.newrelic.agent.stats.StatsBase)19 Tracer (com.newrelic.agent.tracers.Tracer)10 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)9 Test (org.junit.Test)9 TokenImpl (com.newrelic.agent.TokenImpl)6 Transaction (com.newrelic.agent.Transaction)6 StartAndThenLink (com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink)6 ResponseTimeStatsImpl (com.newrelic.agent.stats.ResponseTimeStatsImpl)4 CountStats (com.newrelic.agent.stats.CountStats)3 MetricData (com.newrelic.agent.MetricData)2 MockNormalizer (com.newrelic.agent.MockNormalizer)1 TracedMetricData (com.newrelic.agent.introspec.TracedMetricData)1 SimpleStatsEngine (com.newrelic.agent.stats.SimpleStatsEngine)1 StatsEngine (com.newrelic.agent.stats.StatsEngine)1 TransactionStats (com.newrelic.agent.stats.TransactionStats)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1