Search in sources :

Example 21 with TokenImpl

use of com.newrelic.agent.TokenImpl 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 22 with TokenImpl

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

the class TransactionAsyncRootFirstTest method testStartAndThenLinkExpireAllBeforeFinish.

@Test
public void testStartAndThenLinkExpireAllBeforeFinish() throws InterruptedException {
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
    tx.getTransactionActivity().tracerStarted(rootTracer);
    TokenImpl token = (TokenImpl) tx.getToken();
    rootTracer.finish(Opcodes.RETURN, 0);
    // second expire should do nothing
    StartAndThenLink activity1 = new StartAndThenLink(token, false, false);
    activity1.start();
    activity1.join();
    tx.expireAllTokensForCurrentTransaction();
    verifyDataTwo(activity1, tx, token);
}
Also used : Transaction(com.newrelic.agent.Transaction) TokenImpl(com.newrelic.agent.TokenImpl) Tracer(com.newrelic.agent.tracers.Tracer) StartAndThenLink(com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink) Test(org.junit.Test)

Example 23 with TokenImpl

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

the class TransactionAsyncRootFirstTest method testStartAndThenLinkExpireBeforeEnd.

@Test
public void testStartAndThenLinkExpireBeforeEnd() throws InterruptedException {
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
    tx.getTransactionActivity().tracerStarted(rootTracer);
    TokenImpl token = (TokenImpl) tx.getToken();
    rootTracer.finish(Opcodes.RETURN, 0);
    TransactionAsyncUtility.StartAndThenLink activity1 = new TransactionAsyncUtility.StartAndThenLink(token, true, false);
    activity1.start();
    activity1.join();
    verifyDataTwo(activity1, tx, token);
}
Also used : StartAndThenLink(com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink) Transaction(com.newrelic.agent.Transaction) TransactionAsyncUtility(com.newrelic.agent.TransactionAsyncUtility) TokenImpl(com.newrelic.agent.TokenImpl) Tracer(com.newrelic.agent.tracers.Tracer) StartAndThenLink(com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink) Test(org.junit.Test)

Example 24 with TokenImpl

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

the class TransactionAsyncRootFirstTest method testStartAndThenLinkExpireAllFromToken.

@Test
public void testStartAndThenLinkExpireAllFromToken() throws InterruptedException {
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
    tx.getTransactionActivity().tracerStarted(rootTracer);
    TokenImpl token = (TokenImpl) tx.getToken();
    rootTracer.finish(Opcodes.RETURN, 0);
    // second expire should do nothing
    StartAndThenLink activity1 = new StartAndThenLink(token, false, false);
    activity1.start();
    activity1.join();
    token.getTransaction().expireAllTokens();
    verifyDataTwo(activity1, tx, token);
}
Also used : Transaction(com.newrelic.agent.Transaction) TokenImpl(com.newrelic.agent.TokenImpl) Tracer(com.newrelic.agent.tracers.Tracer) StartAndThenLink(com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink) Test(org.junit.Test)

Example 25 with TokenImpl

use of com.newrelic.agent.TokenImpl 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

TokenImpl (com.newrelic.agent.TokenImpl)37 Test (org.junit.Test)37 Transaction (com.newrelic.agent.Transaction)35 Tracer (com.newrelic.agent.tracers.Tracer)35 StartAndThenLink (com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink)31 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)6 StatsBase (com.newrelic.agent.stats.StatsBase)6 TransactionAsyncUtility (com.newrelic.agent.TransactionAsyncUtility)5 WeakRefTransaction (com.newrelic.agent.WeakRefTransaction)1