Search in sources :

Example 21 with StartAndThenLink

use of com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink in project newrelic-java-agent by newrelic.

the class TransactionAsyncRootLastTest method testStartAndThenLinkExpireAll.

@Test
public void testStartAndThenLinkExpireAll() throws InterruptedException {
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
    tx.getTransactionActivity().tracerStarted(rootTracer);
    TokenImpl token = (TokenImpl) tx.getToken();
    // second expire should do nothing
    StartAndThenLink activity1 = new StartAndThenLink(token, false, false);
    activity1.start();
    activity1.join();
    rootTracer.finish(Opcodes.RETURN, 0);
    // tx no longer on thread and so this will not work
    Transaction.getTransaction().expireAllTokensForCurrentTransaction();
    Assert.assertNull(data);
    Assert.assertNull(stats);
    // need to reference the tx directly
    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 22 with StartAndThenLink

use of com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink in project newrelic-java-agent by newrelic.

the class TransactionAsyncRootLastTest method testStartAndThenLinkExpireInMainBefore.

@Test
public void testStartAndThenLinkExpireInMainBefore() throws InterruptedException {
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
    tx.getTransactionActivity().tracerStarted(rootTracer);
    TokenImpl token = (TokenImpl) tx.getToken();
    // second expire should do nothing
    StartAndThenLink activity1 = new StartAndThenLink(token, false, false);
    activity1.start();
    activity1.join();
    token.expire();
    rootTracer.finish(Opcodes.RETURN, 0);
    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 StartAndThenLink

use of com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink in project newrelic-java-agent by newrelic.

the class TransactionAsyncStartThenLinkTest method testStartAndThenLinkExpireInMain.

@Test
public void testStartAndThenLinkExpireInMain() throws InterruptedException {
    Transaction.clearTransaction();
    Transaction tx = Transaction.getTransaction();
    Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
    tx.getTransactionActivity().tracerStarted(rootTracer);
    TokenImpl token = (TokenImpl) tx.getToken();
    // second expire should do nothing
    StartAndThenLink activity1 = new StartAndThenLink(token, false, false);
    activity1.start();
    activity1.join();
    rootTracer.finish(Opcodes.RETURN, 0);
    token.expire();
    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 24 with StartAndThenLink

use of com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink in project newrelic-java-agent by newrelic.

the class TransactionAsyncStartThenLinkTest 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();
    // second expire should do nothing
    StartAndThenLink activity1 = new StartAndThenLink(token, false, false);
    activity1.start();
    activity1.join();
    tx.expireAllTokensForCurrentTransaction();
    rootTracer.finish(Opcodes.RETURN, 0);
    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 StartAndThenLink

use of com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink in project newrelic-java-agent by newrelic.

the class TransactionAsyncStartThenLinkTest method testStartAndThenLinkExpireBothFinishBefore.

@Test
public void testStartAndThenLinkExpireBothFinishBefore() 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, true, true);
    activity1.start();
    activity1.join();
    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)

Aggregations

TokenImpl (com.newrelic.agent.TokenImpl)27 Transaction (com.newrelic.agent.Transaction)27 StartAndThenLink (com.newrelic.agent.TransactionAsyncUtility.StartAndThenLink)27 Tracer (com.newrelic.agent.tracers.Tracer)27 Test (org.junit.Test)27 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)6 StatsBase (com.newrelic.agent.stats.StatsBase)6