use of com.newrelic.agent.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class TransactionTimeTest method testTransactionTimesWebTransaction.
@Test
public void testTransactionTimesWebTransaction() throws InterruptedException {
doWebWork();
// verify count on stats
Assert.assertNotNull(stats);
ResponseTimeStats stat = stats.getScopedStats().getOrCreateResponseTimeStats("Custom/test.newrelic.test.agent.TransactionTimeTest/hello1");
Assert.assertNotNull(stat);
Assert.assertEquals(1, stat.getCallCount());
stat = stats.getScopedStats().getOrCreateResponseTimeStats("Custom/test.newrelic.test.agent.TransactionTimeTest/hello2");
Assert.assertNotNull(stat);
Assert.assertEquals(1, stat.getCallCount());
// verify total time
double expected = data.getRootTracer().getDuration() / 1000000000.0;
Assert.assertEquals(expected, stats.getUnscopedStats().getOrCreateResponseTimeStats("WebTransaction/Uri/mytest").getTotal(), .0001);
Assert.assertEquals(expected, stats.getUnscopedStats().getOrCreateResponseTimeStats("WebTransactionTotalTime/Uri/mytest").getTotal(), .0001);
}
use of com.newrelic.agent.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class ApiTest method testSetRequestAndResponse.
@Test
public void testSetRequestAndResponse() {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("blah"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(request, response);
tracer.finish(0, null);
Assert.assertEquals(1, txList.size());
Assert.assertEquals("/mytest", txList.get(0).getRequestUri(AgentConfigImpl.ATTRIBUTES));
TransactionStats stats = apiTestHelper.tranStats;
ResponseTimeStats dispatcherStats = stats.getUnscopedStats().getOrCreateResponseTimeStats("HttpDispatcher");
Assert.assertEquals(1, dispatcherStats.getCallCount());
Assert.assertEquals(1, stats.getUnscopedStats().getOrCreateResponseTimeStats("WebTransaction/Uri/mytest").getCallCount());
Assert.assertEquals(1, stats.getUnscopedStats().getApdexStats("Apdex/Uri/mytest").getApdexSatisfying());
Assert.assertEquals(1, stats.getUnscopedStats().getApdexStats("Apdex").getApdexSatisfying());
Assert.assertEquals(1, stats.getUnscopedStats().getOrCreateResponseTimeStats(MetricNames.WEB_TRANSACTION).getCallCount());
Assert.assertEquals(0, stats.getUnscopedStats().getOrCreateResponseTimeStats(MetricNames.OTHER_TRANSACTION_ALL).getCallCount());
}
use of com.newrelic.agent.stats.ResponseTimeStats in project newrelic-java-agent by newrelic.
the class TransactionAsyncRootFirstTest method testStartAndThenLinkMultipleSameTokens.
@Test
public void testStartAndThenLinkMultipleSameTokens() throws InterruptedException {
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
tx.getTransactionActivity().tracerStarted(rootTracer);
TokenImpl token1 = (TokenImpl) tx.getToken();
rootTracer.finish(Opcodes.RETURN, 0);
StartAndThenLink activity1 = new StartAndThenLink(token1, false, false);
activity1.start();
activity1.join();
StartAndThenLink activity2 = new StartAndThenLink(token1, true, false);
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());
Assert.assertNotNull(data1);
Assert.assertNotNull(data2);
Assert.assertEquals(1, data1.getCallCount());
Assert.assertEquals(2, 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 TransactionAsyncRootFirstTest method verifyDataTwo.
private void verifyDataTwo(StartAndThenLink 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 TransactionAsyncRootFirstTest method testStartAndThenLinkMultipleSameTokensExireOrig.
@Test
public void testStartAndThenLinkMultipleSameTokensExireOrig() throws InterruptedException {
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
Tracer rootTracer = TransactionAsyncUtility.createDispatcherTracer(this, "hi");
tx.getTransactionActivity().tracerStarted(rootTracer);
TokenImpl token1 = (TokenImpl) tx.getToken();
rootTracer.finish(Opcodes.RETURN, 0);
StartAndThenLink activity1 = new StartAndThenLink(token1, false, false);
activity1.start();
activity1.join();
StartAndThenLink activity2 = new StartAndThenLink(token1, true, false);
activity2.start();
activity2.join();
token1.expire();
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());
Assert.assertNotNull(data1);
Assert.assertNotNull(data2);
Assert.assertEquals(1, data1.getCallCount());
Assert.assertEquals(2, data2.getCallCount());
Map<String, StatsBase> unscoped = stats.getUnscopedStats().getStatsMap();
Assert.assertEquals(((ResponseTimeStats) unscoped.get("WebTransactionTotalTime")).getTotal(), data1.getTotal() + data2.getTotal(), .001);
}
Aggregations