use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class ApiTest method testNoExceptionRecordMetric.
@Test
public void testNoExceptionRecordMetric() throws Exception {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
String name = "roger";
tx.getTransactionActivity().getTransactionStats().getUnscopedStats().getApdexStats(name);
try {
tx.getTransactionActivity().getTransactionStats().getUnscopedStats().getStats(name);
Assert.fail("expected java.lang.RuntimeException");
} catch (RuntimeException e) {
// expected
}
NewRelic.recordMetric("roger", 1.0f);
}
use of com.newrelic.agent.tracers.ClassMethodSignature 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.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class ApiTest method testSetRequestAndResponseThenSetTxName.
@Test
public void testSetRequestAndResponseThenSetTxName() {
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);
NewRelic.setTransactionName("Test", "Foo");
tracer.finish(0, null);
Assert.assertEquals("WebTransaction/Test/Foo", tx.getPriorityTransactionName().getName());
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class ApiTest method testSetTransactionNameNoStartingForwardSlash.
@Test
public void testSetTransactionNameNoStartingForwardSlash() {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
NewRelic.setTransactionName("Test", "foo");
Assert.assertEquals("OtherTransaction/Test/foo", tx.getPriorityTransactionName().getName());
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class ApiTest method createDispatcherTracer.
private BasicRequestRootTracer createDispatcherTracer() {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
return new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
}
Aggregations