use of com.newrelic.agent.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class TransactionAsyncRootLastTest 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();
StartAndThenLink activity1 = new StartAndThenLink(token1, true, false);
activity1.start();
activity1.join();
StartAndThenLink activity2 = new StartAndThenLink(token2, false, true);
activity2.start();
activity2.join();
rootTracer.finish(Opcodes.RETURN, 0);
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.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class TransactionAsyncStartThenLinkTest method verifyDataTwo.
private void verifyDataTwo(Activity activity, Transaction tx, TokenImpl token) {
waitForTransaction();
TransactionAsyncUtility.basicDataVerify(data, stats, activity, 2);
Map<String, StatsBase> scoped = stats.getScopedStats().getStatsMap();
ResponseTimeStats data1 = (ResponseTimeStats) scoped.get("RequestDispatcher");
ResponseTimeStats data2 = (ResponseTimeStats) scoped.get("Java/java.lang.Object/root" + token.toString());
Assert.assertNotNull(data1);
Assert.assertNotNull(data2);
Assert.assertEquals(1, data1.getCallCount());
Assert.assertEquals(1, data2.getCallCount());
Map<String, StatsBase> unscoped = stats.getUnscopedStats().getStatsMap();
Assert.assertEquals(((ResponseTimeStats) unscoped.get("WebTransactionTotalTime")).getTotal(), data1.getTotal() + data2.getTotal(), .001);
}
use of com.newrelic.agent.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class TransactionAsyncStartThenLinkTest 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();
StartAndThenLink activity1 = new StartAndThenLink(token1, true, false);
activity1.start();
activity1.join();
StartAndThenLink activity2 = new StartAndThenLink(token2, false, true);
activity2.start();
activity2.join();
rootTracer.finish(Opcodes.RETURN, 0);
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.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class FlyweightTracerTest method test.
@Trace(dispatcher = true)
@Test
public void test() {
int count = 100000;
callManyTimes(count);
Transaction transaction = Transaction.getTransaction();
TransactionStats transactionStats = transaction.getTransactionActivity().getTransactionStats();
ResponseTimeStats time = transactionStats.getScopedStats().getOrCreateResponseTimeStats("Java/test.newrelic.test.agent.FlyweightTracerTest/fastMethodDude");
ResponseTimeStats dude = transactionStats.getUnscopedStats().getOrCreateResponseTimeStats("Dude");
ResponseTimeStats man = transactionStats.getUnscopedStats().getOrCreateResponseTimeStats("Man");
Assert.assertEquals(count, time.getCallCount());
Assert.assertEquals(count, dude.getCallCount());
Assert.assertEquals(count, man.getCallCount());
}
use of com.newrelic.agent.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class TraceAnnotationTest method testRollup.
@Test
public void testRollup() throws Exception {
Transaction transaction = new Callable<Transaction>() {
@Trace(dispatcher = true, rollupMetricName = "Rollup1")
@Override
public Transaction call() throws Exception {
return Transaction.getTransaction();
}
}.call();
Assert.assertNotNull(tranStats);
ResponseTimeStats stats = tranStats.getUnscopedStats().getOrCreateResponseTimeStats("Rollup1");
Assert.assertNotNull(stats);
Assert.assertEquals(1, stats.getCallCount());
}
Aggregations