use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class TransactionAsyncEdgeCaseTest method testLinkAfterExpireTxStillInProgress2.
@Test
public void testLinkAfterExpireTxStillInProgress2() throws InterruptedException {
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "outer-hi");
tx.getTransactionActivity().tracerStarted(rootTracer);
TokenImpl token = (TokenImpl) tx.getToken();
Tracer defaultTracer = TransactionAsyncUtility.createDefaultTracer("mymethod1");
tx.getTransactionActivity().tracerStarted(defaultTracer);
defaultTracer.finish(Opcodes.RETURN, 0);
token.expire();
Assert.assertNull(data);
Assert.assertNull(stats);
LinkFail activity1 = new LinkFail(token);
activity1.start();
activity1.join();
rootTracer.finish(Opcodes.RETURN, 0);
waitForTransaction();
Assert.assertNotNull(data);
Assert.assertNotNull(stats);
Assert.assertFalse(activity1.linkResult);
Assert.assertFalse(Transaction.linkTxOnThread(token));
Assert.assertEquals(2, count);
}
use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class TransactionAsyncEdgeCaseTest method testLinkAfterExpireTxNotInProgress.
@Test
public void testLinkAfterExpireTxNotInProgress() throws InterruptedException {
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "outer-hi");
tx.getTransactionActivity().tracerStarted(rootTracer);
TokenImpl token = (TokenImpl) tx.getToken();
Tracer defaultTracer = TransactionAsyncUtility.createDefaultTracer("mymethod1");
tx.getTransactionActivity().tracerStarted(defaultTracer);
defaultTracer.finish(Opcodes.RETURN, 0);
Thread.sleep(250);
ServiceFactory.getTransactionService().processQueue();
Thread.sleep(500);
Assert.assertFalse(token.expire());
rootTracer.finish(Opcodes.RETURN, 0);
Assert.assertFalse(Transaction.linkTxOnThread(token));
waitForTransaction();
Assert.assertNotNull(data);
Assert.assertNotNull(stats);
Assert.assertFalse(Transaction.linkTxOnThread(token));
Assert.assertEquals(1, data.getTransactionActivities().size());
}
use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class TransactionAsyncEdgeCaseTest method testLinkSameThreadTwoTracers.
@Test
public void testLinkSameThreadTwoTracers() throws InterruptedException {
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
tx.getTransactionActivity().tracerStarted(rootTracer);
TokenImpl token = (TokenImpl) tx.getToken();
Transaction.linkTxOnThread(token);
Tracer defaultTracer = TransactionAsyncUtility.createDefaultTracer("mymethod");
tx.getTransactionActivity().tracerStarted(defaultTracer);
token.expire();
defaultTracer.finish(Opcodes.RETURN, 0);
rootTracer.finish(Opcodes.RETURN, 0);
waitForTransaction();
Assert.assertNotNull(data);
Assert.assertNotNull(stats);
Assert.assertEquals(1, data.getTransactionActivities().size());
Collection<Tracer> tracers = data.getTracers();
Assert.assertEquals(2, tracers.size() + 1);
Iterator<Tracer> it = tracers.iterator();
while (it.hasNext()) {
Tracer t = it.next();
Assert.assertEquals("Custom/mymethod", t.getMetricName());
}
Assert.assertEquals("RequestDispatcher", data.getRootTracer().getMetricName());
Map<String, StatsBase> metrics = stats.getScopedStats().getStatsMap();
ResponseTimeStatsImpl sb = (ResponseTimeStatsImpl) metrics.get("Custom/mymethod");
Assert.assertEquals(1, sb.getCallCount());
sb = (ResponseTimeStatsImpl) metrics.get("RequestDispatcher");
Assert.assertEquals(1, sb.getCallCount());
}
use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class TransactionAsyncUtility method basicDataVerify.
public static Collection<Tracer> basicDataVerify(TransactionData data, TransactionStats stats, Activity activity, int count) {
Assert.assertNotNull(data);
Assert.assertNotNull(stats);
Assert.assertTrue(activity.wasTxEqual);
Assert.assertTrue(activity.isTxaNotNull);
Assert.assertEquals(count, data.getTransactionActivities().size());
Collection<Tracer> tracers = data.getTracers();
Assert.assertEquals(count, tracers.size() + 1);
for (Tracer current : tracers) {
String segmentName = current.getTransactionSegmentName();
Assert.assertTrue(segmentName.startsWith("RequestDispatcher/com.newrelic.agent.transaction.TransactionAsync") || segmentName.startsWith("Java/java.lang.Object/rootcom.newrelic.agent.TokenImpl@"));
}
TransactionAsyncUtility.verifyUnscoped(stats);
return tracers;
}
use of com.newrelic.agent.tracers.Tracer in project newrelic-java-agent by newrelic.
the class TransactionDataTest method getRootTracer.
@Test
public void getRootTracer() {
Tracer expected = Mockito.mock(Tracer.class);
Mockito.when(tx.getRootTracer()).thenReturn(expected);
TransactionData txd = getTxData(tx);
Tracer result = txd.getRootTracer();
Assert.assertNotNull(result);
Assert.assertSame(expected, result);
}
Aggregations