Search in sources :

Example 26 with TokenImpl

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

the class TransactionAsyncRootFirstTest method testStartAndThenLinkExpireAfter.

@Test
public void testStartAndThenLinkExpireAfter() 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, false, true);
    activity1.start();
    activity1.join();
    Thread.sleep(250);
    ServiceFactory.getTransactionService().processQueue();
    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 27 with TokenImpl

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

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

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

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

the class TransactionAsyncRootLastTest 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();
    TransactionAsyncUtility.StartAndThenLink activity1 = new TransactionAsyncUtility.StartAndThenLink(token, true, false);
    activity1.start();
    activity1.join();
    rootTracer.finish(Opcodes.RETURN, 0);
    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 30 with TokenImpl

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

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