use of com.newrelic.agent.TokenImpl in project newrelic-java-agent by newrelic.
the class TransactionAsyncRootFirstTest method testStartAndThenLinkMultipleDiffTokensExpireAll.
@Test
public void testStartAndThenLinkMultipleDiffTokensExpireAll() 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();
rootTracer.finish(Opcodes.RETURN, 0);
StartAndThenLink activity1 = new StartAndThenLink(token1, false, false);
activity1.start();
activity1.join();
StartAndThenLink activity2 = new StartAndThenLink(token2, false, false);
activity2.start();
activity2.join();
tx.expireAllTokensForCurrentTransaction();
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);
}
use of com.newrelic.agent.TokenImpl in project newrelic-java-agent by newrelic.
the class TransactionAsyncRootFirstTest 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();
rootTracer.finish(Opcodes.RETURN, 0);
// second expire should do nothing
StartAndThenLink activity1 = new StartAndThenLink(token, false, false);
activity1.start();
activity1.join();
token.expire();
verifyDataTwo(activity1, tx, token);
}
use of com.newrelic.agent.TokenImpl in project newrelic-java-agent by newrelic.
the class TransactionAsyncRootFirstTest 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();
rootTracer.finish(Opcodes.RETURN, 0);
// second expire should do nothing
StartAndThenLink activity1 = new StartAndThenLink(token, false, false);
activity1.start();
activity1.join();
// 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);
}
use of com.newrelic.agent.TokenImpl in project newrelic-java-agent by newrelic.
the class TransactionAsyncRootFirstTest 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();
rootTracer.finish(Opcodes.RETURN, 0);
StartAndThenLink activity1 = new StartAndThenLink(token1, true, false);
activity1.start();
activity1.join();
StartAndThenLink activity2 = new StartAndThenLink(token2, false, true);
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());
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);
}
use of com.newrelic.agent.TokenImpl in project newrelic-java-agent by newrelic.
the class TransactionAsyncRootLastTest 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();
StartAndThenLink activity1 = new StartAndThenLink(token, false, true);
activity1.start();
activity1.join();
rootTracer.finish(Opcodes.RETURN, 0);
verifyDataTwo(activity1, tx, token);
}
Aggregations