use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class TransactionTimesTest method createDefaultTraer.
private DefaultTracer createDefaultTraer(String methodName) {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), methodName, "()V");
return new DefaultTracer(tx, sig, this);
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class TransactionTimesTest method createDispatcherTracer.
// Create a Tracer for tests that require one.
private OtherRootTracer createDispatcherTracer() {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
return new OtherRootTracer(tx, sig, this, new OtherTransSimpleMetricNameFormat("myMetricName"));
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class ApiTest method setRequestAndResponseFirstWins.
@Test
public void setRequestAndResponseFirstWins() throws Exception {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("otherRootTracer"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
Request firstRequest = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "firstWins", "", ""));
Response firstResponse = new FirstResponse(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(firstRequest, firstResponse);
Request secondRequest = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "thisIsABug", "", ""));
Response secondResponse = new SecondResponse(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(secondRequest, secondResponse);
tracer.finish(0, null);
Assert.assertEquals(firstRequest.getRequestURI(), tx.getDispatcher().getUri());
Assert.assertEquals(firstResponse.getStatus(), ((WebRequestDispatcher) tx.getDispatcher()).getStatus());
String name = tx.getPriorityTransactionName().getName();
Assert.assertNotEquals("WebTransaction/Uri/thisIsABug", name);
Assert.assertEquals("WebTransaction/Uri/firstWins", name);
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class ApiTest method setRequestAndResponseNullRequestResponse.
@Test
public void setRequestAndResponseNullRequestResponse() {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("otherRootTracer"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
NewRelic.setRequestAndResponse(null, null);
Assert.assertFalse(tx.isWebRequestSet());
Assert.assertFalse(tx.isWebResponseSet());
tracer.finish(0, null);
Assert.assertTrue(tx.isWebTransaction());
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class ApiTest method testSetUserName.
@Test
public void testSetUserName() {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(request, response);
NewRelic.setUserName("myname");
Assert.assertEquals("myname", tx.getUserAttributes().get("user"));
}
Aggregations