use of com.newrelic.agent.tracers.OtherRootTracer 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.OtherRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testSetTransactionNameMoreThanOnce.
@Test
public void testSetTransactionNameMoreThanOnce() {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
NewRelic.setTransactionName("Test", "/foo");
NewRelic.setTransactionName("Test", "/dude");
NewRelic.setTransactionName("Test", "/bar");
Assert.assertEquals("OtherTransaction/Test/bar", tx.getPriorityTransactionName().getName());
}
use of com.newrelic.agent.tracers.OtherRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method testIgnoreTransactionNotSet.
@Test
public void testIgnoreTransactionNotSet() {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
Assert.assertTrue("Transaction should be ignored", !tx.isIgnore());
}
use of com.newrelic.agent.tracers.OtherRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method nameTransactionThenSetRequestAndResponse.
@Test
public void nameTransactionThenSetRequestAndResponse() {
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));
tracer.nameTransaction(TransactionNamePriority.CUSTOM_HIGH);
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("WebTransaction/Custom/test.newrelic.test.agent.api.ApiTest/", tx.getPriorityTransactionName().getName());
}
use of com.newrelic.agent.tracers.OtherRootTracer in project newrelic-java-agent by newrelic.
the class TransactionDispatcherTest method testSetResponseOnly.
@Test
public void testSetResponseOnly() {
Transaction tx = Transaction.getTransaction(true);
/* Start a tracer and end it so that the transaction runs the dispatcher
transactionActivityWithResponseFinished code
*/
OtherRootTracer rootTracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), null, new SimpleMetricNameFormat(""));
tx.getTransactionActivity().tracerStarted(rootTracer);
MockHttpResponse response = new MockHttpResponse();
response.setResponseStatus(418);
response.setResponseStatusMessage("tea");
tx.setWebResponse(response);
rootTracer.finish(null);
assertEquals(418, tx.getStatus());
assertEquals("tea", tx.getStatusMessage());
// Make sure the status code was set in time for the Apdex calculation.
StatsEngine statsEngine = ServiceFactory.getStatsService().getStatsEngineForHarvest(tx.getApplicationName());
assertEquals(1, statsEngine.getApdexStats(MetricName.create(MetricNames.APDEX)).getApdexFrustrating());
}
Aggregations